feat: admin endpoints to reset username sync flags

Add POST /v1/admin/users/{pubkey}/reset-username and
POST /v1/admin/users/reset-usernames to clear manual_username
and last_synced_at so nostr profile sync re-evaluates users.
Includes OpenAPI docs, audit actions, and tests.
This commit is contained in:
2026-05-06 19:31:13 +00:00
parent c6bdb7f825
commit fe2b95258d
7 changed files with 290 additions and 0 deletions

View File

@@ -290,6 +290,48 @@ paths:
'200': { description: Deleted }
'401': { description: Unauthorized }
'404': { description: Not found }
/v1/admin/users/reset-usernames:
post:
tags: [Admin]
summary: Reset all usernames (admin)
description: |
Clears `manual_username` and `last_synced_at` for every active user so
the nostr profile sync worker re-evaluates each one on its next cycle.
The stored username is left untouched until the worker overwrites it
with fresh kind:0 metadata. Idempotent.
security: [{ AdminAPIKey: [] }]
responses:
'200':
description: Reset count
content:
application/json:
schema:
type: object
properties:
reset: { type: integer, description: "Number of users whose sync flags were cleared" }
'401': { description: Unauthorized }
/v1/admin/users/{pubkey}/reset-username:
post:
tags: [Admin]
summary: Reset username for a user (admin)
description: |
Clears `manual_username` and `last_synced_at` for the given user so the
nostr profile sync worker re-evaluates their kind:0 metadata on its next
cycle. The stored username is left untouched until the worker overwrites
it. Idempotent.
security: [{ AdminAPIKey: [] }]
parameters:
- in: path
name: pubkey
required: true
schema: { type: string }
responses:
'200':
description: Reset
content: { application/json: { schema: { $ref: '#/components/schemas/User' } } }
'400': { description: Validation error, content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
'401': { description: Unauthorized }
'404': { description: Not found }
/v1/admin/users/{pubkey}/extend:
post:
tags: [Admin]