WIP: feat: Missing notification when another user comments on a post the user commented on #142

Draft
typosaurus wants to merge 5 commits from typosaurus/132-missing-notification-when-another-user-comments-on-a-post-th into master
Showing only changes of commit 1e1eb61b75 - Show all commits

View File

@ -362,6 +362,29 @@ def create_comment_record(
comment_url,
)
# Notify previous commenters on this post (participation)
posts = get_table("posts")
post = posts.find_one(uid=target_uid)
if not post:
post = posts.find_one(slug=target_uid)
if post:
post_owner_uid = post["user_uid"]
previous_commenters = set()
for c in get_table("comments").find(
target_type="post", target_uid=target_uid, deleted_at=None
):
cu = c["user_uid"]
if cu != user["uid"] and cu != post_owner_uid:
previous_commenters.add(cu)
for cu in previous_commenters:
create_notification(
cu,
"participation",
f"{user['username']} also commented on this post",
user["uid"],
comment_url,
)
create_mention_notifications(content, user["uid"], comment_url)
schedule_correction(user, "comments", comment_uid, request)
schedule_modification(user, "comments", comment_uid, request)