From 5d6cb1ba46a39e9e3c607172f3a3e22b7dfd84ba Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 24 Feb 2023 04:04:11 +0200 Subject: [PATCH] add push notifs for modmail --- files/routes/static.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/files/routes/static.py b/files/routes/static.py index b0d9938c0..9f57704af 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -252,12 +252,14 @@ def submit_contact(v): execute_under_siege(v, new_comment, new_comment.body_html, 'modmail') new_comment.top_comment_id = new_comment.id - admins = g.db.query(User).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL']) + admin_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL']).all()] - for admin in admins.all(): - notif = Notification(comment_id=new_comment.id, user_id=admin.id) + for admin_id in admin_ids: + notif = Notification(comment_id=new_comment.id, user_id=admin_id) g.db.add(notif) + g.db.flush() + push_notif(admin_ids, 'New modmail', new_comment.body, f'{SITE_FULL}/notifications/modmail') return redirect("/contact?msg=Your message has been sent to the admins!")