From 8ac49ae4168065c1e200ce1e60913c2431f43e40 Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 6 Mar 2024 00:32:39 +0200 Subject: [PATCH] do notify jannies --- files/routes/comments.py | 53 ++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 48dbba795..8b6eda91e 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -303,40 +303,42 @@ def comment(v): execute_longpostbot(c, level, body, body_html, post_target, v) execute_zozbot(c, level, post_target, v) - if c.pinned != "Admin Note": - notify_users = NOTIFY_USERS(body, v, ghost=c.ghost, obj=c, commenters_ping_post_id=commenters_ping_post_id) + notify_users = NOTIFY_USERS(body, v, ghost=c.ghost, obj=c, commenters_ping_post_id=commenters_ping_post_id) - if notify_users == 'everyone': - alert_everyone(c.id) - else: - push_notif(notify_users, f'New mention of you by @{c.author_name}', c.body, c) + if notify_users == 'everyone': + alert_everyone(c.id) + else: + push_notif(notify_users, f'New mention of you by @{c.author_name}', c.body, c) - if c.level == 1 and posting_to_post: - subscriber_ids = [x[0] for x in g.db.query(Subscription.user_id).filter(Subscription.post_id == post_target.id, Subscription.user_id != v.id)] + if c.level == 1 and posting_to_post: + subscriber_ids = [x[0] for x in g.db.query(Subscription.user_id).filter(Subscription.post_id == post_target.id, Subscription.user_id != v.id)] - notify_users.update(subscriber_ids) + notify_users.update(subscriber_ids) - push_notif(subscriber_ids, f'New comment in subscribed thread by @{c.author_name}', c.body, c) + push_notif(subscriber_ids, f'New comment in subscribed thread by @{c.author_name}', c.body, c) - if parent_user.id != v.id and notify_op: - notify_users.add(parent_user.id) + if parent_user.id != v.id and notify_op: + notify_users.add(parent_user.id) - notify_users -= BOT_IDs + notify_users -= BOT_IDs - if v.shadowbanned or c.is_banned: - notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.admin_level >= PERMS['USER_SHADOWBAN']).all()] + if v.shadowbanned or c.is_banned: + notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.admin_level >= PERMS['USER_SHADOWBAN']).all()] - for x in notify_users: - n = Notification(comment_id=c.id, user_id=x) - g.db.add(n) + if c.pinned == "Admin Note": + notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.admin_level >= PERMS['ADMIN_NOTES']).all()] - if parent_user.id != v.id and notify_op: - if isinstance(parent, User): - title = f"New comment on your wall by @{c.author_name}" - else: - title = f'New reply by @{c.author_name}' + for x in notify_users: + n = Notification(comment_id=c.id, user_id=x) + g.db.add(n) - push_notif({parent_user.id}, title, c.body, c) + if parent_user.id != v.id and notify_op: + if isinstance(parent, User): + title = f"New comment on your wall by @{c.author_name}" + else: + title = f'New reply by @{c.author_name}' + + push_notif({parent_user.id}, title, c.body, c) vote = CommentVote(user_id=v.id, comment_id=c.id, @@ -668,6 +670,9 @@ def edit_comment(cid, v): else: notify_users -= BOT_IDs + if c.pinned == "Admin Note": + notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.admin_level >= PERMS['ADMIN_NOTES']).all()] + for x in notify_users: notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).one_or_none() if not notif: