summaryrefslogtreecommitdiffstats
path: root/activities
diff options
context:
space:
mode:
authorAndrew Godwin2022-12-05 20:26:21 -0700
committerAndrew Godwin2022-12-05 20:26:21 -0700
commit5b82c76defd8016df137087e5ce55b44cf017399 (patch)
treeff96b3a84622219130ec0d46a1b52566b3d6b3c6 /activities
parent9fe2e6676c32b93023ae301be587a8ab0d93120f (diff)
downloadtakahe-5b82c76defd8016df137087e5ce55b44cf017399.tar.gz
takahe-5b82c76defd8016df137087e5ce55b44cf017399.tar.bz2
takahe-5b82c76defd8016df137087e5ce55b44cf017399.zip
Shorten mention names when linkified
Fixes #121
Diffstat (limited to 'activities')
-rw-r--r--activities/models/post.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/activities/models/post.py b/activities/models/post.py
index 5ca5a1b..daf61e8 100644
--- a/activities/models/post.py
+++ b/activities/models/post.py
@@ -279,8 +279,12 @@ class Post(StatorModel):
def replacer(match):
precursor = match.group(1)
handle = match.group(2).lower()
+ if "@" in handle:
+ short_handle = handle.split("@", 1)[0]
+ else:
+ short_handle = handle
if handle in possible_matches:
- return f'{precursor}<a href="{possible_matches[handle]}">@{handle}</a>'
+ return f'{precursor}<a href="{possible_matches[handle]}">@{short_handle}</a>'
else:
return match.group()