Use find_tags when calculating tags from RawContentMixin.raw_content

Closes #70
merge-requests/159/head
Jason Robinson 2020-02-17 21:06:20 +02:00
rodzic 712c6d2c46
commit b72ce5b870
2 zmienionych plików z 4 dodań i 3 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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):