in push notifs: link the post I was mentioned in

master
Aevann 2023-02-26 11:37:44 +02:00
parent 7301be5f78
commit fd9e1c3fec
2 changed files with 11 additions and 5 deletions

View File

@ -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):

View File

@ -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