1
0
Fork 0

Link hashtags in status content

This commit is contained in:
Christof Dorner 2022-12-17 21:00:32 +01:00
parent c68304a99b
commit ba0fcccfc5
2 changed files with 16 additions and 5 deletions

View file

@ -116,12 +116,16 @@ class CreateStatus(View):
status.mention_users.add(status.reply_parent.user)
# inspect the text for hashtags
for (tag, mention_hashtag) in find_hashtags(content).items():
for (mention_text, mention_hashtag) in find_hashtags(content).items():
# add them to status mentions fk
status.mention_hashtags.add(mention_hashtag)
# TODO: turn the mention into a link
content = content
# turn the mention into a link
content = re.sub(
rf"{mention_text}\b(?!@)",
rf'<a href="{mention_hashtag.remote_id}">{mention_text}</a>',
content,
)
# deduplicate mentions
status.mention_users.set(set(status.mention_users.all()))