From 6755cbf28afecdfe94d5233e81e106f8a28dcbe0 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 24 Feb 2023 03:56:46 +0200 Subject: [PATCH] move an if condition to push_notif() --- files/helpers/alerts.py | 7 +++++++ files/routes/comments.py | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 4400e9aa6..b82390352 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -140,6 +140,13 @@ def push_notif(uids, title, body, url): if VAPID_PUBLIC_KEY == DEFAULT_CONFIG_VALUE: return + if isinstance(url, tuple): + cid, posting_to_submission = url + if posting_to_submission: + url = f'{SITE_FULL}/comment/{cid}?read=true#context' + else: + url = f'{SITE_FULL}/@{c.wall_user.username}/wall/comment/{cid}?read=true#context' + if len(body) > PUSH_NOTIF_LIMIT: body = body[:PUSH_NOTIF_LIMIT] + "..." diff --git a/files/routes/comments.py b/files/routes/comments.py index aab6b49ca..1b914c320 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -327,13 +327,8 @@ def comment(v:User): if len(c.body) > PUSH_NOTIF_LIMIT: notifbody = c.body[:PUSH_NOTIF_LIMIT] + '...' else: notifbody = c.body - if posting_to_submission: - url = f'{SITE_FULL}/comment/{c.id}?read=true#context' - else: - url = f'{SITE_FULL}/@{c.wall_user.username}/wall/comment/{c.id}?read=true#context' - if parent_user.id != AEVANN_ID: - push_notif({parent_user.id}, title, notifbody, url) + push_notif({parent_user.id}, title, notifbody, (c.id,posting_to_submission)) vote = CommentVote(user_id=v.id, comment_id=c.id,