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`.
This commit is contained in:
2026-06-27 22:31:34 +00:00
parent e773067106
commit 6f340a6818
60 changed files with 1626 additions and 97 deletions
+30
View File
@@ -444,3 +444,33 @@ def test_public_detail_is_indexable(app_server):
r = requests.get(f"{BASE_URL}/projects/{slug}", headers={"X-API-KEY": key})
assert r.status_code == 200, r.text[:300]
assert '<meta name="robots" content="index,follow">' in r.text
def test_viewing_project_marks_notification_read(app_server):
from devplacepy.database import resolve_object_url
name, uid, key = _signup_project_visibility()
project = _create_project_project_visibility(key, "Notif Mark Read")
refresh_snapshot()
target_url = resolve_object_url("project", project["uid"])
notif_uid = generate_uid()
get_table("notifications").insert(
{
"uid": notif_uid,
"user_uid": uid,
"type": "comment",
"message": "someone commented on your project",
"related_uid": project["uid"],
"target_url": target_url,
"read": False,
"created_at": datetime.now(timezone.utc).isoformat(),
}
)
refresh_snapshot()
r = requests.get(f"{BASE_URL}{target_url}", headers={"X-API-KEY": key})
assert r.status_code == 200, r.text[:200]
refresh_snapshot()
assert bool(get_table("notifications").find_one(uid=notif_uid)["read"]) is True