feat: add audit logging for admin trash restore/purge and notification clear actions

- Record audit events in `admin_trash_restore` and `admin_trash_purge` endpoints with target metadata
- Log `notification.read.all` event when user clears devRant notification feed
- Include `devrant` as a valid origin in audit categories
- Add `admin_section` and `pagination_query` fields to audit and backup schemas for UI consistency
This commit is contained in:
2026-06-16 05:08:58 +00:00
parent 1934dd5727
commit 99ed5c4f15
24 changed files with 466 additions and 186 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ CATEGORY_BY_PREFIX: dict[str, str] = {
EVENT_RESULTS = ("success", "failure", "denied")
ACTOR_KINDS = ("user", "guest", "system", "cli", "service")
ORIGINS = ("web", "api", "devii", "cli", "service", "scheduler")
ORIGINS = ("web", "api", "devii", "cli", "service", "scheduler", "devrant")
def category_for(event_key: str) -> str:
@@ -605,6 +605,19 @@ ACTIONS: tuple[Action, ...] = (
params=(path("uid", "SEO job uid returned by seo_diagnostics."),),
requires_auth=False,
),
Action(
name="seo_report",
method="GET",
path="/tools/seo/{uid}/report",
summary="Read a finished SEO audit report",
description=(
"Returns the full audit for a finished SEO job: overall score and grade, per-category "
"scores, per-check results, per-page details, and site-wide checks. Use it after "
"seo_status reports status 'done' to explain what passed, what failed, and how to improve."
),
params=(path("uid", "SEO job uid returned by seo_diagnostics."),),
requires_auth=False,
),
Action(
name="deepsearch",
method="POST",
+4 -5
View File
@@ -52,11 +52,10 @@ def _user_comments(user: dict, viewer: Optional[dict]) -> list:
return []
target_uids = list({comment["target_uid"] for comment in comments})
posts_table = get_table("posts")
rant_ids = {}
for target_uid in target_uids:
post = posts_table.find_one(uid=target_uid)
if post:
rant_ids[target_uid] = int(post["id"])
rant_ids = {
post["uid"]: int(post["id"])
for post in posts_table.find(posts_table.table.columns.uid.in_(target_uids))
}
comment_uids = [comment["uid"] for comment in comments]
authors = get_users_by_uids([user["uid"]])
user_scores = {user["uid"]: get_user_stars(user["uid"])}