From ce38cc0f721801e8408e19bef93b62cce1067a8b Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 18 Aug 2023 05:21:56 +0300 Subject: [PATCH] fix snappy pinging --- files/helpers/actions.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index e23b9f69bc..04d30e7eb7 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -55,13 +55,11 @@ def execute_snappy(post, v): if post.sub and g.db.query(Exile.user_id).filter_by(user_id=SNAPPY_ID, sub=post.sub).one_or_none(): return - group_members = [] - ghost = post.ghost snappy = get_account(SNAPPY_ID) - ping_cost = None + ping_cost = 0 post_ping_group_count = len(list(group_mention_regex.finditer(post.body))) @@ -206,12 +204,10 @@ def execute_snappy(post, v): app_id=None, body=body, body_html=body_html, - ghost=ghost + ghost=ghost, + ping_cost=ping_cost, ) - if ping_cost: - c.ping_cost += ping_cost - g.db.add(c) check_slots_command(c, v, snappy) @@ -242,10 +238,11 @@ def execute_snappy(post, v): g.db.flush() - for x in group_members: - n = Notification(comment_id=c.id, user_id=x) - g.db.add(n) - push_notif({x}, f'New mention of you by @Snappy', c.body, c) + if c.ping_cost: + for x in group.member_ids: + n = Notification(comment_id=c.id, user_id=x) + g.db.add(n) + push_notif({x}, f'New mention of you by @Snappy', c.body, c) c.top_comment_id = c.id