diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 3625cdcd6..e1e6ac909 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -103,7 +103,7 @@ def notif_comment2(p): return create_comment(text_html), text -def add_notif(cid, uid, text): +def add_notif(cid, uid, text, pushnotif_url): if uid in bots: return existing = g.db.query(Notification.user_id).filter_by(comment_id=cid, user_id=uid).one_or_none() @@ -111,7 +111,13 @@ def add_notif(cid, uid, text): notif = Notification(comment_id=cid, user_id=uid) g.db.add(notif) - push_notif({uid}, 'New notification', text, f'{SITE_FULL}/comment/{cid}?read=true#context') + if not pushnotif_url: + pushnotif_url = f'{SITE_FULL}/comment/{cid}?read=true#context' + + if ' has mentioned you: [' in text: + text = text.split(':')[0] + '!' + + push_notif({uid}, 'New notification', text, pushnotif_url) def NOTIFY_USERS(text, v): diff --git a/files/routes/posts.py b/files/routes/posts.py index 5e66237bc..f0fde7a8e 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -52,7 +52,7 @@ def publish(pid, v): if notify_users: cid, text = notif_comment2(post) for x in notify_users: - add_notif(cid, x, text) + add_notif(cid, x, text, pushnotif_url=post.permalink) cache.delete_memoized(frontlist) @@ -332,7 +332,7 @@ def edit_post(pid, v): if notify_users: cid, text = notif_comment2(p) for x in notify_users: - add_notif(cid, x, text) + add_notif(cid, x, text, pushnotif_url=p.permalink) if v.id == p.author_id: if int(time.time()) - p.created_utc > 60 * 3: p.edited_utc = int(time.time()) @@ -748,7 +748,7 @@ def submit_post(v:User, sub=None): if notify_users: cid, text = notif_comment2(post) for x in notify_users: - add_notif(cid, x, text) + add_notif(cid, x, text, pushnotif_url=post.permalink) if v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in f'{post.body}{post.title}'.lower() and sub != 'chudrama': post.is_banned = True