Compare commits

..
Author SHA1 Message Date
Typosaurus aae9c3698c ticket #89 attempt 1
DevPlace CI / test (pull_request) Failing after 1h25m28s
2026-07-23 01:35:14 +00:00
7 changed files with 9 additions and 95 deletions
File diff suppressed because one or more lines are too long
-31
View File
@@ -360,37 +360,6 @@ def create_comment_record(
comment_url,
)
if target_type == "post":
posts_table = get_table("posts")
post_record = posts_table.find_one(uid=target_uid)
if not post_record:
post_record = posts_table.find_one(slug=target_uid)
commenter_uids = set()
for c in get_table("comments").find(
target_type="post", target_uid=target_uid, deleted_at=None
):
commenter_uids.add(c["user_uid"])
commenter_uids.discard(user["uid"])
if post_record:
commenter_uids.discard(post_record["user_uid"])
if parent_uid:
parent_comment = get_table("comments").find_one(
uid=parent_uid, deleted_at=None
)
if parent_comment and parent_comment["user_uid"] != user["uid"]:
commenter_uids.discard(parent_comment["user_uid"])
for commenter_uid in commenter_uids:
create_notification(
commenter_uid,
"thread_comment",
f"{user['username']} also commented on a post you commented on",
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)
-1
View File
@@ -19,7 +19,6 @@ NOTIFICATION_TYPES = [
{"key": "harvest_stolen", "label": "Farm raids", "description": "Someone steals a ready build from your Code Farm"},
{"key": "award", "label": "Awards", "description": "Someone gives you an award on your profile"},
{"key": "system", "label": "System alerts", "description": "Platform infrastructure alerts (e.g. the AI gateway going down)"},
{"key": "thread_comment", "label": "Thread comments", "description": "Someone else comments on a post you commented on"},
]
+3
View File
@@ -44,6 +44,7 @@ from devplacepy.templating import templates, jinja_unread_count
from devplacepy.cache import TTLCache
from devplacepy.responses import respond, wants_json, json_error
from devplacepy.schemas import LandingOut, ValidationErrorOut
from devplacepy.attachments import get_attachments_batch
from fastapi.responses import JSONResponse
from devplacepy.utils import get_current_user, time_ago, safe_next, client_ip
from devplacepy.seo import base_seo_context, site_url, website_schema
@@ -671,6 +672,7 @@ def _landing_recent_posts(blocked):
authors = get_users_by_uids(author_uids)
comment_counts = get_comment_counts_by_post_uids(post_uids)
upvotes, downvotes = get_vote_counts(post_uids)
attachments_map = get_attachments_batch("post", post_uids)
for p in raw_posts:
posts.append(
{
@@ -680,6 +682,7 @@ def _landing_recent_posts(blocked):
"comment_count": comment_counts.get(p["uid"], 0),
"stars": upvotes.get(p["uid"], 0) - downvotes.get(p["uid"], 0),
"slug": p.get("slug", "") or p["uid"],
"attachments": attachments_map.get(p["uid"], []),
}
)
if not blocked:
+3 -1
View File
@@ -7,7 +7,6 @@ from devplacepy.models import ProfileForm
from fastapi.responses import HTMLResponse, JSONResponse
from devplacepy.database import (
get_table,
db,
get_customization_prefs,
get_notification_prefs,
get_user_stars,
@@ -48,6 +47,7 @@ from devplacepy.utils import (
)
from devplacepy.responses import respond, action_result, wants_json
from devplacepy.schemas import ProfileOut
from devplacepy.attachments import get_attachments_batch
from devplacepy.avatar import avatar_url, avatar_seed
from devplacepy.seo import (
base_seo_context,
@@ -188,8 +188,10 @@ async def profile_page(
else set()
)
polls_map = get_polls_by_post_uids(post_uids, current_user)
attachments_map = get_attachments_batch("post", post_uids)
for item in posts:
uid = item["post"]["uid"]
item["attachments"] = attachments_map.get(uid, [])
item["reactions"] = reactions_map.get(uid, {"counts": {}, "mine": []})
item["bookmarked"] = uid in bookmark_set
item["poll"] = polls_map.get(uid)
+2 -1
View File
@@ -5,7 +5,7 @@ from __future__ import annotations
from typing import Any, Optional
from devplacepy.schemas.base import _Out
from devplacepy.schemas.content import UserOut
from devplacepy.schemas.content import AttachmentOut, UserOut
class AuthPageOut(_Out):
@@ -38,6 +38,7 @@ class LandingPostOut(_Out):
comment_count: int = 0
stars: int = 0
slug: str = ""
attachments: list[AttachmentOut] = []
class TrendingTopicOut(_Out):
-60
View File
@@ -384,66 +384,6 @@ def test_comment_notification_on_post(app_server, browser, seeded_db):
ctx_b.close()
def test_thread_comment_notification(app_server, browser, seeded_db):
from tests.conftest import login_user
ctx_a = browser.new_context(viewport={"width": 1400, "height": 900})
ctx_b = browser.new_context(viewport={"width": 1400, "height": 900})
pa = ctx_a.new_page()
pb = ctx_b.new_page()
pa.set_default_timeout(15000)
pb.set_default_timeout(15000)
login_user(pa, seeded_db["alice"])
login_user(pb, seeded_db["bob"])
pa.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
pa.locator(".feed-fab").first.wait_for(state="visible", timeout=10000)
pa.locator(".feed-fab").first.click()
pa.fill("#post-content", "Post for thread comment notification test")
pa.locator("#create-post-modal button.btn-primary:has-text('Post')").click()
pa.wait_for_url("**/posts/*", timeout=10000, wait_until="domcontentloaded")
post_url = pa.url
pb.goto(post_url, wait_until="domcontentloaded")
pb.wait_for_timeout(1000)
comment_textarea = pb.locator("form.comment-form textarea[name='content']").first
comment_textarea.wait_for(state="visible", timeout=10000)
comment_textarea.fill("Bob's top-level comment")
pb.locator("button.comment-form-submit").first.click()
pb.wait_for_timeout(1500)
pb_body = pb.locator("body").text_content()
assert "Internal Server Error" not in pb_body, f"Bob got 500: {pb_body[:300]}"
pa.goto(post_url, wait_until="domcontentloaded")
pa.wait_for_timeout(1000)
comment_textarea = pa.locator("form.comment-form textarea[name='content']").first
comment_textarea.wait_for(state="visible", timeout=10000)
comment_textarea.fill("Alice also comments on her own post")
pa.locator("button.comment-form-submit").first.click()
pa.wait_for_timeout(1500)
pa_body = pa.locator("body").text_content()
assert "Internal Server Error" not in pa_body, f"Alice got 500: {pa_body[:300]}"
pb.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded")
pb.wait_for_timeout(2000)
body = pb.locator("body").text_content()
assert "Internal Server Error" not in body, (
f"Got 500 error on notifications: {body[:500]}"
)
assert "alice_test" in body, (
f"Expected 'alice_test' in notifications, got: {body[:500]}"
)
assert "also commented" in body, (
f"Expected 'also commented' in notifications, got: {body[:500]}"
)
ctx_a.close()
ctx_b.close()
def test_follow_notification(app_server, browser, seeded_db):
from tests.conftest import login_user