Add thread notifications, SEO topic pages, and fix quiz auto-advance

Notifications: a new "thread" type notifies every other commenter on a
post whenever anyone comments on it, disregarding reply hierarchy -
excluding the actor and whoever already got a comment/reply
notification for that same event, so no one is double-notified.
Implemented via a background-deferred fan-out mirroring the existing
mention-notification pattern.

SEO: discussion_forum_posting() now embeds up to 20 of a post's
comments as nested schema.org Comment entities (not just an aggregate
count), and a new /topics hub plus /topics/{topic} pages give the
feed's topic filter real, independently crawlable/indexable URLs -
/feed?topic=X was never indexable since its canonical strips the
query string back to bare /feed. Both are wired end to end (schemas,
Devii actions, docs API, sitemap, locustfile load-test coverage).

Quiz player: the auto-advance to the next question used to hide the
just-answered slide in the same tick as rendering the grade, so on
any multi-question quiz the Correct/Not correct feedback was never
actually visible before the view moved on. Delayed via setTimeout,
with the pending timer cleared on manual navigation and on
disconnect so it can't race or fire on a removed component.

Also includes other local changes already in progress in this
working tree before this session (messaging, push delivery,
deepsearch jobs, game economy, quiz builder) - verified by the full
suite passing (3467 tests) but not authored or individually reviewed
in this session.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VL9Xn57W5UR3HZbbuuzxdK
This commit is contained in:
2026-09-03 08:47:57 +02:00
co-authored by Claude Sonnet 5
parent afb4799869
commit 572e022584
93 changed files with 2788 additions and 331 deletions
+144
View File
@@ -351,3 +351,147 @@ def test_comment_links_multiple_attachments(app_server):
assert u1 in r.text and u2 in r.text, (
"both attachments must be linked and displayed on the comment"
)
def test_thread_notifies_other_commenters_disregarding_hierarchy(app_server):
owner, _ = _session_comments()
title = f"thread-test-{int(time.time() * 1000)}"
post_uid = _create_post_comments(owner, title)
first, first_name = _session_comments()
first.post(
f"{BASE_URL}/comments/create",
data={
"content": "First commenter",
"target_type": "post",
"post_uid": post_uid,
"target_uid": post_uid,
},
allow_redirects=False,
)
refresh_snapshot()
first_uid = _db_user(first_name)["uid"]
second, _ = _session_comments()
second.post(
f"{BASE_URL}/comments/create",
data={
"content": "Second commenter, unrelated to the first's comment",
"target_type": "post",
"post_uid": post_uid,
"target_uid": post_uid,
},
allow_redirects=False,
)
refresh_snapshot()
assert get_table("notifications").count(user_uid=first_uid, type="thread") == 1
def test_thread_does_not_notify_self_when_commenting_again(app_server):
owner, _ = _session_comments()
title = f"thread-self-{int(time.time() * 1000)}"
post_uid = _create_post_comments(owner, title)
commenter, commenter_name = _session_comments()
commenter.post(
f"{BASE_URL}/comments/create",
data={
"content": "First comment from this user",
"target_type": "post",
"post_uid": post_uid,
"target_uid": post_uid,
},
allow_redirects=False,
)
refresh_snapshot()
commenter_uid = _db_user(commenter_name)["uid"]
commenter.post(
f"{BASE_URL}/comments/create",
data={
"content": "Same user comments again on the same post",
"target_type": "post",
"post_uid": post_uid,
"target_uid": post_uid,
},
allow_redirects=False,
)
refresh_snapshot()
assert get_table("notifications").count(user_uid=commenter_uid, type="thread") == 0
def test_thread_notification_excludes_actor_and_already_notified_participants(app_server):
owner, owner_name = _session_comments()
title = f"thread-excl-{int(time.time() * 1000)}"
post_uid = _create_post_comments(owner, title)
refresh_snapshot()
owner_uid = _db_user(owner_name)["uid"]
owner.post(
f"{BASE_URL}/comments/create",
data={
"content": "Owner's own top-level comment",
"target_type": "post",
"post_uid": post_uid,
"target_uid": post_uid,
},
allow_redirects=False,
)
refresh_snapshot()
assert get_table("notifications").count(user_uid=owner_uid, type="thread") == 0
parent = get_table("comments").find_one(target_uid=post_uid, user_uid=owner_uid)
replier, replier_name = _session_comments()
replier.post(
f"{BASE_URL}/comments/create",
data={
"content": "Reply to the post owner's comment",
"target_type": "post",
"post_uid": post_uid,
"target_uid": post_uid,
"parent_uid": parent["uid"],
},
allow_redirects=False,
)
refresh_snapshot()
assert get_table("notifications").count(user_uid=owner_uid, type="reply") == 1
assert get_table("notifications").count(user_uid=owner_uid, type="thread") == 0
third, _ = _session_comments()
third.post(
f"{BASE_URL}/comments/create",
data={
"content": "Another top-level comment",
"target_type": "post",
"post_uid": post_uid,
"target_uid": post_uid,
},
allow_redirects=False,
)
refresh_snapshot()
assert get_table("notifications").count(user_uid=owner_uid, type="comment") == 1
assert get_table("notifications").count(user_uid=owner_uid, type="thread") == 0
replier_uid = _db_user(replier_name)["uid"]
assert get_table("notifications").count(user_uid=replier_uid, type="thread") == 1
def test_post_page_embeds_comment_as_nested_schema(app_server):
s, _ = _session_comments()
title = f"schema-comment-{int(time.time() * 1000)}"
post_uid = _create_post_comments(s, title)
slug = get_table("posts").find_one(uid=post_uid)["slug"]
unique_comment_text = f"a schema-visible comment {int(time.time() * 1000)}"
s.post(
f"{BASE_URL}/comments/create",
data={
"content": unique_comment_text,
"target_type": "post",
"post_uid": post_uid,
"target_uid": post_uid,
},
allow_redirects=False,
)
r = requests.get(f"{BASE_URL}/posts/{slug}", allow_redirects=False)
assert r.status_code == 200
assert '"@type": "Comment"' in r.text
assert unique_comment_text in r.text