kopia lustrzana https://gitlab.com/jaywink/federation
Use find_tags when calculating tags from RawContentMixin.raw_content
Closes #70merge-requests/159/head
rodzic
712c6d2c46
commit
b72ce5b870
|
@ -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
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
Ładowanie…
Reference in New Issue