From e37031c4ddf0dc601991ca51c3c2c248729b8ed1 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 24 Feb 2023 04:36:25 +0200 Subject: [PATCH] make sure g.db.flush() is always above _push_notif_thread --- files/helpers/actions.py | 2 -- files/helpers/alerts.py | 4 +--- files/helpers/offsitementions.py | 1 - files/helpers/sanitize.py | 3 --- files/routes/oauth.py | 1 - files/routes/static.py | 1 - 6 files changed, 1 insertion(+), 11 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 5431b7154..61f948f99 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -265,7 +265,6 @@ def execute_zozbot(c:Comment, level:int, post_target:post_target_type, v): post_target.comment_count += 3 g.db.add(post_target) - g.db.flush() push_notif({v.id}, f'New reply by @zozbot', "zoz", (c2.id,posting_to_submission)) def execute_longpostbot(c:Comment, level:int, body, body_html, post_target:post_target_type, v:User): @@ -310,7 +309,6 @@ def execute_longpostbot(c:Comment, level:int, body, body_html, post_target:post_ post_target.comment_count += 3 g.db.add(post_target) - g.db.flush() push_notif({v.id}, f'New reply by @longpostbot', c2.body, (c2.id,posting_to_submission)) def execute_antispam_submission_check(title, v, url): diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index eb88d87c0..a602b30a1 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -38,7 +38,6 @@ def send_repeatable_notification(uid, text): 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 @@ -46,7 +45,6 @@ def send_repeatable_notification(uid, text): 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') @@ -113,7 +111,6 @@ def add_notif(cid, uid, text): 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') @@ -162,6 +159,7 @@ def push_notif(uids, title, body, url): subscriptions = g.db.query(PushSubscription.subscription_json).filter(PushSubscription.user_id.in_(uids)).all() subscriptions = [x[0] for x in subscriptions] + g.db.flush() gevent.spawn(_push_notif_thread, subscriptions, title, body, url) diff --git a/files/helpers/offsitementions.py b/files/helpers/offsitementions.py index ac6174bad..a868b3001 100644 --- a/files/helpers/offsitementions.py +++ b/files/helpers/offsitementions.py @@ -123,5 +123,4 @@ def notify_mentions(mentions, send_to=None, mention_str='site mention'): notif = Notification(comment_id=new_comment.id, user_id=send_to) g.db.add(notif) - g.db.flush() push_notif({send_to}, f'New mention of you on reddit by /u/{author}', new_comment.body, f'{SITE_FULL}/comment/{new_comment.id}?read=true#context') diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 91120390e..c1bc6ecc0 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -177,7 +177,6 @@ def send_repeatable_notification_duplicated(uid, text): 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 @@ -185,7 +184,6 @@ def send_repeatable_notification_duplicated(uid, text): 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') @@ -229,7 +227,6 @@ def execute_blackjack(v, target, body, type): n = Notification(comment_id=target.id, user_id=id) g.db.add(n) - g.db.flush() push_notif(notified_ids, f'Blackjack by @{v.username}', target.body, (target.id,bool(target.wall_user_id))) extra_info = None diff --git a/files/routes/oauth.py b/files/routes/oauth.py index e9b674bdc..20f13be1e 100644 --- a/files/routes/oauth.py +++ b/files/routes/oauth.py @@ -84,7 +84,6 @@ def request_api_keys(v): notif = Notification(comment_id=new_comment.id, user_id=admin_id) g.db.add(notif) - g.db.flush() push_notif(admin_ids, 'New notification', new_comment.body, f'{SITE_FULL}/comment/{new_comment.id}?read=true#context') return redirect('/settings/apps') diff --git a/files/routes/static.py b/files/routes/static.py index bf202f1bb..dcf6e239f 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -258,7 +258,6 @@ def submit_contact(v): notif = Notification(comment_id=new_comment.id, user_id=admin_id) g.db.add(notif) - g.db.flush() push_notif(admin_ids, f'New modmail from @{v.username}', new_comment.body, f'{SITE_FULL}/notifications/modmail') return redirect("/contact?msg=Your message has been sent to the admins!")