Fix #132: Missing notification when another user comments on a post the user commented on #133
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "typosaurus/ticket-132"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolves #132.
Plan
Implementation Plan: Notify Previous Commenters on New Comments
1. Add New Notification Type
File:
devplacepy/database/notifications.py"thread_comment"to theNOTIFICATION_TYPEStuple (or list)."system". No message template needed here; the message will be constructed at call site.2. Modify
create_comment_record()indevplacepy/content.pyLocation: After existing notification logic (line 361), before the audit event emission (line 373).
Scope: This change must apply to both top-level comments and replies, but only for targets of type
"post".Steps:
After the existing
if target_type == "post":block, add a new inner block that fires only when the comment is not a reply (parent_uid is None) or, for consistency, after the reply notification has been sent. A simpler approach: place the new logic after the existingif-elseblock, guarded byif target_type == "post":.Query the
commentstable for distinctuser_uidvalues where:target_type = 'post'target_uid = post_uid(the post UID, already available astarget_uid)deleted_at = Noneuser["uid"])"comment"type)"reply"type)Use a single SQL query with
DISTINCTor fetch all rows and deduplicate in Python.For each qualifying
user_uid, call:Ensure no duplicate notifications are created if a user qualifies for both a reply and this new notification (already handled by exclusions).
Edge cases:
3. Update E2E Test Coverage
File:
tests/e2e/notifications/index.pyAdd a new test function, e.g.
test_thread_comment_notification, that:post_owner,first_commenter,second_commenter.post_ownercreates a post.first_commenteradds a top-level comment on that post.second_commenteradds another top-level comment on the same post.first_commenterreceives exactly one notification of type"thread_comment"(message should contain"also commented").post_ownerreceives exactly one notification of type"comment"(unchanged).second_commenterreceives no self-notification.Place this test after existing comment notification tests (around line 381). Use the same Playwright fixtures and helpers as the surrounding tests to avoid introducing new dependencies.
4. Run Verification
Execute the project’s test command:
Initially target the single file to validate the new test. Then run the full suite:
to confirm no regressions.
Definition of Done
"thread_comment"is added toNOTIFICATION_TYPESindevplacepy/database/notifications.py.devplacepy/content.py,create_comment_record()contains new logic that queries thecommentstable for prior commenters on the same post (excluding the comment author, post owner, and parent commenter if replying) and callscreate_notification()for each with type"thread_comment".test_thread_comment_notificationexists intests/e2e/notifications/index.pythat verifies a previous commenter receives a notification when another user comments on the same post.pip install -e '.[dev]' -q && python -m pytest) passes with zero errors.Opened automatically by Typosaurus.
Checkout
From your project repository, check out a new branch and test the changes.