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.
remotes/1693045480750635534/spooky-22
Snakes 2022-06-30 05:36:45 -04:00
parent 0b95dc8cd1
commit 467eb4408a
1 changed files with 6 additions and 4 deletions

View File

@ -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"<a href='/h/{hole}'>/h/{hole}</a> 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)