From 5b82c76defd8016df137087e5ce55b44cf017399 Mon Sep 17 00:00:00 2001
From: Andrew Godwin
Date: Mon, 5 Dec 2022 20:26:21 -0700
Subject: Shorten mention names when linkified
Fixes #121
---
activities/models/post.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
(limited to 'activities')
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}@{handle}'
+ return f'{precursor}@{short_handle}'
else:
return match.group()
--
cgit v1.2.3