feat: tickets-by-user endpoint + Nostr-driven inventory sync #15

Merged
padreug merged 3 commits from tickets-nostr-sync into main 2026-05-23 18:50:53 +00:00
Showing only changes of commit b0d089d3c9 - Show all commits

feat: also publish allow_fiat + fiat_currency in NIP-52 tags
Some checks failed
lint.yml / feat: also publish allow_fiat + fiat_currency in NIP-52 tags (pull_request) Failing after 0s
lint.yml / feat: also publish allow_fiat + fiat_currency in NIP-52 tags (push) Failing after 0s

The buyer-side webapp Purchase button needs allow_fiat to know
whether to surface the fiat method, and fiat_currency for the
conversion-preview label. Without these in the published Nostr
event, the buyer would either have to REST-fetch the LNbits event
again (defeats the inventory-sync goal) or guess.

Same backwards-compat reasoning as the four counter tags — tags
are AIO additions outside the NIP-52 spec; unknown tags are
ignored by spec-compliant clients.

- tickets_allow_fiat: "true" when the organizer enabled the fiat
  toggle. Omitted otherwise so the on-the-wire payload stays
  small for the common Lightning-only case.
- tickets_fiat_currency: only emitted when allow_fiat is on
  (otherwise it'd be ambiguous what the value represents).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Padreug 2026-05-23 20:37:19 +02:00

View file

@ -44,11 +44,13 @@ def build_nip52_event(event: Event, pubkey: str) -> NostrEvent:
start - unix timestamp (31923) or YYYY-MM-DD (31922) start - unix timestamp (31923) or YYYY-MM-DD (31922)
end - same encoding (optional) end - same encoding (optional)
image, location, t (categories) - optional image, location, t (categories) - optional
tickets_available - current remaining capacity (omitted when unlimited) tickets_available - current remaining capacity (omitted when unlimited)
tickets_sold - running paid-count (always emitted; clients can tickets_sold - running paid-count (always emitted; clients can
derive original_capacity = available + sold) derive original_capacity = available + sold)
tickets_price - price_per_ticket (always emitted; 0 means free) tickets_price - price_per_ticket (always emitted; 0 means free)
tickets_currency - the currency string tickets_currency - the currency string
tickets_allow_fiat - "true" when fiat checkout is enabled (omitted otherwise)
tickets_fiat_currency - the fiat settle currency (only when allow_fiat)
Content: event.info Content: event.info
The four ticket_* tags are AIO custom additions outside the NIP-52 The four ticket_* tags are AIO custom additions outside the NIP-52
@ -100,6 +102,12 @@ def build_nip52_event(event: Event, pubkey: str) -> NostrEvent:
tags.append(["tickets_sold", str(event.sold)]) tags.append(["tickets_sold", str(event.sold)])
tags.append(["tickets_price", str(event.price_per_ticket)]) tags.append(["tickets_price", str(event.price_per_ticket)])
tags.append(["tickets_currency", event.currency]) tags.append(["tickets_currency", event.currency])
# Fiat-checkout config — only emitted when allow_fiat is on so
# clients can branch the buy UI without re-reading the schema.
if event.allow_fiat:
tags.append(["tickets_allow_fiat", "true"])
if event.fiat_currency:
tags.append(["tickets_fiat_currency", event.fiat_currency])
nostr_event = NostrEvent( nostr_event = NostrEvent(
pubkey=pubkey, pubkey=pubkey,