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
+7 -2
View File
@@ -25,6 +25,7 @@ from devplacepy.database import (
get_user_relations,
get_user_media,
search_users_by_username,
mark_notifications_read_by_target,
)
from devplacepy.content import can_view_project, enrich_items
from devplacepy.utils import (
@@ -40,7 +41,7 @@ from devplacepy.utils import (
)
from devplacepy.responses import respond, action_result
from devplacepy.schemas import ProfileOut
from devplacepy.avatar import avatar_url
from devplacepy.avatar import avatar_url, avatar_seed
from devplacepy.seo import (
base_seo_context,
site_url,
@@ -120,6 +121,10 @@ async def profile_page(
profile_user = users.find_one(username=username)
if not profile_user:
raise not_found("Profile not found")
if current_user:
mark_notifications_read_by_target(
current_user["uid"], f"/profile/{profile_user['username']}"
)
profile_user["stars"] = get_user_stars(profile_user["uid"])
rank = get_user_rank(profile_user["uid"])
follow_counts = get_follow_counts(profile_user["uid"])
@@ -321,7 +326,7 @@ async def profile_page(
description=desc,
robots=robots,
og_type="profile",
og_image=avatar_url("multiavatar", profile_user["username"], 256),
og_image=avatar_url("multiavatar", avatar_seed(profile_user), 256),
breadcrumbs=[
{"name": "Home", "url": "/feed"},
{