2026-06-13 16:32:33 +02:00
|
|
|
# retoor <retoor@molodetz.nl>
|
|
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
import requests
|
|
|
|
|
from tests.conftest import BASE_URL
|
|
|
|
|
from devplacepy.database import get_table
|
|
|
|
|
JSON_content_negotiation = {"Accept": "application/json"}
|
|
|
|
|
_counter_content_negotiation = [0]
|
|
|
|
|
def _session_content_negotiation(password="secret123"):
|
|
|
|
|
_counter_content_negotiation[0] += 1
|
|
|
|
|
name = f"cn{int(time.time() * 1000)}{_counter_content_negotiation[0]}"
|
|
|
|
|
s = requests.Session()
|
|
|
|
|
s.post(
|
|
|
|
|
f"{BASE_URL}/auth/signup",
|
|
|
|
|
data={
|
|
|
|
|
"username": name,
|
|
|
|
|
"email": f"{name}@t.dev",
|
|
|
|
|
"password": password,
|
|
|
|
|
"confirm_password": password,
|
Add the trust and safety subsystem and the App Store compliance work
Implements the moderation and consent obligations a social platform carries,
so the web version and any client that speaks to it enforce the same rules.
Moderation core (services/moderation/, database/moderation.py): a reportable
target registry, the content filter and its choke points, the report queue with
atomic resolution, enforcement actions, consent tracking, maturity gating, and
account deletion with a grace window.
Surfaces: POST /reports plus the member report list, /admin/moderation and the
per-report admin view, /workspaces, terms acceptance at /auth/terms, consent and
account deletion under /profile, the report button and dialog partials, the
maturity gate, and the moderation stylesheet and ReportDialog client.
Every user-generated surface stays reportable by construction: new content tables
are registered in REPORTABLE_TARGETS or listed in UNREPORTABLE_TABLES with a
reason, and the registry test fails the suite on anything left unclassified.
Docs: community guidelines, content moderation, intellectual property, privacy,
terms, contact, and the admin-only moderation operations page, plus the
moderation API group and the Devii moderation actions.
Compliance record: applecomp.md is the requirement register, applechanges.md the
gap analysis against this codebase, and appleimpl.md the implementation design
they resolve to.
Tests cover the report flow, admin moderation, consent, account deletion, terms
acceptance, workspaces, and the registry invariant across the unit, api, and e2e
tiers.
2026-08-09 00:18:20 +02:00
|
|
|
"birth_date": "1990-01-01",
|
|
|
|
|
"accept_terms": "1",
|
2026-06-13 16:32:33 +02:00
|
|
|
},
|
|
|
|
|
allow_redirects=True,
|
|
|
|
|
)
|
|
|
|
|
return s, name
|
2026-06-14 09:48:10 +02:00
|
|
|
PUBLIC_PAGES = ["/feed", "/projects", "/gists", "/news", "/leaderboard", "/issues"]
|
2026-06-13 16:32:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_json_404_error_envelope(app_server):
|
|
|
|
|
r = requests.get(f"{BASE_URL}/posts/does-not-exist-xyz", headers=JSON_content_negotiation)
|
|
|
|
|
assert r.status_code == 404
|
|
|
|
|
assert r.json()["error"]["status"] == 404
|
feat: add per-user avatar seed regeneration with irreversible random avatar replacement
Implement a new `avatar_seed` column on the users table that overrides the username-based seed for Multiavatar generation. Introduce a null-safe `avatar_seed(user)` choke point in `avatar.py` that resolves `user.get("avatar_seed") or user.get("username")`, registered as a Jinja global so every render site (`_avatar_link.html`, `avatar_url(...)` calls, SEO `og_image`, issues ad-hoc dicts, devRant payload/PNG) propagates a regenerated seed. Add `POST /profile/{username}/regenerate-avatar` endpoint (owner-or-admin only) that writes a fresh `generate_uid()` to `avatar_seed`, invalidates the target's user cache, and audits `profile.avatar.regenerate`. The previous seed is overwritten and never stored, making regeneration irreversible. Document the feature in `AGENTS.md` and `README.md`, add the API endpoint to `docs_api.py`, and include the `regenerate_avatar` Devii tool in `CONFIRM_REQUIRED`.
2026-06-28 00:31:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_viewing_post_marks_notification_read(app_server):
|
|
|
|
|
from datetime import datetime, timezone
|
|
|
|
|
from devplacepy.database import (
|
|
|
|
|
get_table,
|
|
|
|
|
refresh_snapshot,
|
|
|
|
|
resolve_object_url,
|
|
|
|
|
)
|
|
|
|
|
from devplacepy.utils import generate_uid
|
|
|
|
|
|
|
|
|
|
session, name = _session_content_negotiation()
|
|
|
|
|
created = session.post(
|
|
|
|
|
f"{BASE_URL}/posts/create",
|
|
|
|
|
headers=JSON_content_negotiation,
|
|
|
|
|
data={
|
|
|
|
|
"title": f"mark read {int(time.time() * 1000)}",
|
|
|
|
|
"content": "post body for notification mark read",
|
|
|
|
|
"topic": "devlog",
|
|
|
|
|
},
|
|
|
|
|
).json()["data"]
|
|
|
|
|
post_uid = created["uid"]
|
|
|
|
|
refresh_snapshot()
|
|
|
|
|
user = get_table("users").find_one(username=name)
|
|
|
|
|
target_url = resolve_object_url("post", post_uid)
|
|
|
|
|
|
|
|
|
|
notif_uid = generate_uid()
|
|
|
|
|
get_table("notifications").insert(
|
|
|
|
|
{
|
|
|
|
|
"uid": notif_uid,
|
|
|
|
|
"user_uid": user["uid"],
|
|
|
|
|
"type": "comment",
|
|
|
|
|
"message": "someone commented",
|
|
|
|
|
"related_uid": post_uid,
|
|
|
|
|
"target_url": f"{target_url}#comment-x",
|
|
|
|
|
"read": False,
|
|
|
|
|
"created_at": datetime.now(timezone.utc).isoformat(),
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
refresh_snapshot()
|
|
|
|
|
|
|
|
|
|
r = session.get(f"{BASE_URL}{target_url}", allow_redirects=True)
|
|
|
|
|
assert r.status_code == 200
|
|
|
|
|
|
|
|
|
|
refresh_snapshot()
|
|
|
|
|
assert bool(get_table("notifications").find_one(uid=notif_uid)["read"]) is True
|