From e1eecfc0f2590c6002aa773ab3fa08145ded75b2 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 20 Aug 2023 05:36:43 +0300 Subject: [PATCH] make sure shadowbanned-cels cant generate push notifs --- files/helpers/alerts.py | 3 +++ files/routes/comments.py | 5 ++--- files/routes/users.py | 14 ++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 8a3ac9255..62c4fbb80 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -215,6 +215,9 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None, followers_pi def push_notif(uids, title, body, url_or_comment): + if g.v.shadowbanned: + return + if VAPID_PUBLIC_KEY == DEFAULT_CONFIG_VALUE: return diff --git a/files/routes/comments.py b/files/routes/comments.py index 45172f12c..946aa3917 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -370,7 +370,7 @@ def comment(v): n = Notification(comment_id=c.id, user_id=x) g.db.add(n) - if parent_user.id != v.id and not v.shadowbanned: + if parent_user.id != v.id: if isinstance(parent, User): title = f"New comment on your wall by @{c.author_name}" else: @@ -710,8 +710,7 @@ def edit_comment(cid, v): if not notif: n = Notification(comment_id=c.id, user_id=x) g.db.add(n) - if not v.shadowbanned: - push_notif({x}, f'New mention of you by @{c.author_name}', c.body, c) + push_notif({x}, f'New mention of you by @{c.author_name}', c.body, c) g.db.flush() diff --git a/files/routes/users.py b/files/routes/users.py index b0b19c6be..12d0f2c03 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -663,12 +663,11 @@ def message2(v, username=None, id=None): g.db.add(notif) - if not v.shadowbanned: - title = f'New message from @{c.author_name}' + title = f'New message from @{c.author_name}' - url = f'{SITE_FULL}/notifications/messages' + url = f'{SITE_FULL}/notifications/messages' - push_notif({user.id}, title, body, url) + push_notif({user.id}, title, body, url) return {"message": "Message sent!"} @@ -745,12 +744,11 @@ def messagereply(v): notif = Notification(comment_id=c.id, user_id=user_id) g.db.add(notif) - if not v.shadowbanned: - title = f'New message from @{c.author_name}' + title = f'New message from @{c.author_name}' - url = f'{SITE_FULL}/notifications/messages' + url = f'{SITE_FULL}/notifications/messages' - push_notif({user_id}, title, body, url) + push_notif({user_id}, title, body, url) top_comment = c.top_comment