From 760b2e6a4d0b3d77f43ac2c3d29283dc4b08ca85 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 24 Feb 2023 04:09:49 +0200 Subject: [PATCH] add push notifs for repeatable notifications --- files/helpers/alerts.py | 6 ++++++ files/helpers/sanitize.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index b82390352..9bb3d21c3 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -37,12 +37,18 @@ def send_repeatable_notification(uid, text): if not existing_notif: notif = Notification(comment_id=c.id, user_id=uid) g.db.add(notif) + + g.db.flush() + push_notif({uid}, 'New notification', text, f'{SITE_FULL}/comment/{c.id}?read=true#context') return cid = create_comment(text_html) notif = Notification(comment_id=cid, user_id=uid) g.db.add(notif) + g.db.flush() + push_notif({uid}, 'New notification', text, f'{SITE_FULL}/comment/{cid}?read=true#context') + def send_notification(uid, text): diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 5821a83cf..da28e5f53 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -176,12 +176,18 @@ def send_repeatable_notification_duplicated(uid, text): if not existing_notif: notif = Notification(comment_id=c.id, user_id=uid) g.db.add(notif) + + g.db.flush() + push_notif({uid}, 'New notification', text, f'{SITE_FULL}/comment/{c.id}?read=true#context') return cid = create_comment_duplicated(text_html) notif = Notification(comment_id=cid, user_id=uid) g.db.add(notif) + g.db.flush() + push_notif({uid}, 'New notification', text, f'{SITE_FULL}/comment/{cid}?read=true#context') + def execute_blackjack(v, target, body, type): if not blackjack or not body: return False