From 467eb4408af3633f1329618c4a6c086d5778a80c Mon Sep 17 00:00:00 2001 From: TLSM Date: Thu, 30 Jun 2022 05:36:45 -0400 Subject: [PATCH] Fix hole_entered notif username. Previously, the on_post_hole_entered notifs to hole followers would contain the username of the admin who moved the post (due to referencing the `v` parameter of whomever performed the action which placed the post in the hole). This has been corrected to use the post author instead. Further, on_post_hole_entered only depends on a post for behavior, though the optional `v` user is used if present. --- files/routes/subs.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/files/routes/subs.py b/files/routes/subs.py index 5226011b18..008cfebd63 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -347,18 +347,20 @@ def rehole_post(v, pid, hole): return {"message": f"Post moved to {sub_to_str}!"} -def on_post_hole_entered(post, v): +def on_post_hole_entered(post, v=None): if not post.sub or not post.subr: return hole = post.subr.name + author = post.author # Notify hole followers - if not post.ghost and not post.private and not post.author.shadowbanned: + if not post.ghost and not post.private and not author.shadowbanned: text = f"/h/{hole} has a new " \ - + f"post: [{post.title}]({post.shortlink}) by @{v.username}" + + f"post: [{post.title}]({post.shortlink}) by @{author.username}" cid = notif_comment(text, autojanny=True) for follow in post.subr.followers: - if follow.user_id == v.id: continue + if follow.user_id == author.id or (v and follow.user_id == v.id): + continue user = get_account(follow.user_id) if post.club and not user.paid_dues: continue add_notif(cid, user.id)