diff --git a/views_api.py b/views_api.py index 7fd3aa0..b7c6a0d 100644 --- a/views_api.py +++ b/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),