feat: POST /republish-all admin endpoint
Loops over approved events and re-emits each NIP-52 calendar event. Useful as a one-shot migration after the publisher's tag set changes (e.g. the tickets_* tag rollout introduced in this PR) so existing events on a deployed instance pick up the new metadata without each organizer having to edit and save. Gated by check_admin (LNbits instance admin), errors swallowed per-event inside the publisher so one bad row doesn't block the rest. Returns a count summary. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b0d089d3c9
commit
05593c9c3c
1 changed files with 24 additions and 0 deletions
24
views_api.py
24
views_api.py
|
|
@ -112,6 +112,30 @@ async def api_events_pending(
|
|||
return await get_pending_events()
|
||||
|
||||
|
||||
@events_api_router.post("/republish-all")
|
||||
async def api_republish_all(
|
||||
admin: Account = Depends(check_admin),
|
||||
) -> dict:
|
||||
"""Force-republish every approved event to Nostr relays. Admin only.
|
||||
|
||||
Used by the catalog-bump migration that introduced the AIO ticket
|
||||
tags: existing events on a deployed instance were published before
|
||||
the publisher learned the new tag set, so they don't carry
|
||||
tickets_available / tickets_sold / etc. until something triggers
|
||||
a republish. This endpoint walks the approved list and re-emits
|
||||
each calendar event so connected clients see the new metadata
|
||||
without waiting for a per-event edit.
|
||||
|
||||
Errors are swallowed per-event (logged inside the publisher) so
|
||||
one bad event doesn't block the rest. Returns a count summary.
|
||||
"""
|
||||
events = await get_all_events()
|
||||
approved = [e for e in events if e.status == "approved" and not e.canceled]
|
||||
for event in approved:
|
||||
await publish_or_delete_nostr_event(event)
|
||||
return {"republished": len(approved), "total": len(events)}
|
||||
|
||||
|
||||
@events_api_router.get("/settings")
|
||||
async def api_get_settings(
|
||||
admin: Account = Depends(check_admin),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue