diff --git a/CHANGELOG.md b/CHANGELOG.md index 14324d1..1ee6bf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ * Add `process_text_links` text utility to linkify URL's in text. -* Add `find_tags` text utility to find hashtags from text. +* Add `find_tags` text utility to find hashtags from text. This utility is used + to improve the tag extraction logic from entities text fields. ([related issue](https://git.feneas.org/jaywink/federation/issues/70)) ### Changed diff --git a/federation/entities/mixins.py b/federation/entities/mixins.py index 13f8ac4..c7a6a1c 100644 --- a/federation/entities/mixins.py +++ b/federation/entities/mixins.py @@ -8,7 +8,7 @@ from commonmark import commonmark from federation.entities.activitypub.enums import ActivityType from federation.entities.utils import get_name_for_profile -from federation.utils.text import process_text_links +from federation.utils.text import process_text_links, find_tags class BaseEntity: @@ -230,7 +230,7 @@ class RawContentMixin(BaseEntity): """Returns a `list` of unique tags contained in `raw_content`.""" if not self.raw_content: return [] - tags = {word.strip("#").lower() for word in self.raw_content.split() if word.startswith("#") and len(word) > 1} + tags = find_tags(self.raw_content) return sorted(tags) def extract_mentions(self):