feat: add soft delete and media tab for user attachments with admin restore

This commit is contained in:
2026-06-11 18:52:56 +00:00
parent c74228bc6c
commit 3862958fae
40 changed files with 1549 additions and 81 deletions
@@ -734,6 +734,30 @@ ACTIONS: tuple[Action, ...] = (
query("page", "Page number, 25 per page."),
),
),
Action(
name="list_media",
method="GET",
path="/profile/{username}?tab=media",
summary="List a user's uploaded media, newest first",
requires_auth=False,
params=(
path("username", "Username whose media to list."),
query("page", "Page number, 24 per page."),
),
),
Action(
name="delete_media",
method="POST",
path="/media/{uid}/delete",
summary="Delete one of your uploaded media attachments",
description=(
"Removes the attachment from the user's Media tab and from any post, project, or "
"gist where it was attached. Show the user the exact media, get explicit "
"confirmation, then call again with confirm=true."
),
requires_auth=True,
params=(path("uid", "Attachment uid to delete."),),
),
Action(
name="view_leaderboard",
method="GET",
@@ -38,6 +38,7 @@ CONFIRM_REQUIRED = {
"customize_reset",
"project_delete_file",
"delete_project",
"delete_media",
}
DESTRUCTIVE_COMMAND = re.compile(
@@ -98,6 +99,12 @@ def confirmation_error(name: str, arguments: dict[str, Any]) -> ToolInputError |
"Deleting a project permanently removes the project and ALL of its files. Ask the user "
"to confirm this explicitly first, then call again with confirm=true."
)
if name == "delete_media":
return ToolInputError(
"Deleting media removes it from every display surface, including its parent post or "
"project. Show the user the exact media, get explicit confirmation, then call again "
"with confirm=true."
)
if (
name == "container_instance_action"
and str(arguments.get("action", "")).strip().lower() == "delete"