feat: tickets-by-user endpoint + Nostr-driven inventory sync #15
1 changed files with 13 additions and 5 deletions
feat: also publish allow_fiat + fiat_currency in NIP-52 tags
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>
commit
b0d089d3c9
|
|
@ -44,11 +44,13 @@ def build_nip52_event(event: Event, pubkey: str) -> NostrEvent:
|
|||
start - unix timestamp (31923) or YYYY-MM-DD (31922)
|
||||
end - same encoding (optional)
|
||||
image, location, t (categories) - optional
|
||||
tickets_available - current remaining capacity (omitted when unlimited)
|
||||
tickets_sold - running paid-count (always emitted; clients can
|
||||
derive original_capacity = available + sold)
|
||||
tickets_price - price_per_ticket (always emitted; 0 means free)
|
||||
tickets_currency - the currency string
|
||||
tickets_available - current remaining capacity (omitted when unlimited)
|
||||
tickets_sold - running paid-count (always emitted; clients can
|
||||
derive original_capacity = available + sold)
|
||||
tickets_price - price_per_ticket (always emitted; 0 means free)
|
||||
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
|
||||
|
||||
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_price", str(event.price_per_ticket)])
|
||||
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(
|
||||
pubkey=pubkey,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue