summaryrefslogtreecommitdiffstats
path: root/activities/models
diff options
context:
space:
mode:
Diffstat (limited to 'activities/models')
-rw-r--r--activities/models/post.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/activities/models/post.py b/activities/models/post.py
index daf61e8..55d2f65 100644
--- a/activities/models/post.py
+++ b/activities/models/post.py
@@ -276,6 +276,8 @@ class Post(StatorModel):
possible_matches[mention.username] = url
possible_matches[f"{mention.username}@{mention.domain_id}"] = url
+ collapse_name: dict[str, str] = {}
+
def replacer(match):
precursor = match.group(1)
handle = match.group(2).lower()
@@ -284,6 +286,10 @@ class Post(StatorModel):
else:
short_handle = handle
if handle in possible_matches:
+ if short_handle not in collapse_name:
+ collapse_name[short_handle] = handle
+ elif collapse_name.get(short_handle) != handle:
+ short_handle = handle
return f'{precursor}<a href="{possible_matches[handle]}">@{short_handle}</a>'
else:
return match.group()