diff --git a/src/modules/activities/services/TicketApiService.ts b/src/modules/activities/services/TicketApiService.ts index a9f3975..432771d 100644 --- a/src/modules/activities/services/TicketApiService.ts +++ b/src/modules/activities/services/TicketApiService.ts @@ -148,6 +148,60 @@ export class TicketApiService { }) } + /** + * Update an existing event. Requires the event's wallet admin key. + * Status is re-derived server-side from admin/auto_approve — a non- + * admin owner editing under `auto_approve=false` lands back at + * `proposed` regardless of the current state. + */ + async updateEvent( + eventId: string, + eventData: CreateEventRequest, + adminKey: string, + ): Promise { + return this.request(`/events/api/v1/events/${eventId}`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + 'X-API-KEY': adminKey, + }, + body: JSON.stringify(eventData), + }) + } + + /** + * Probe whether the current user has LNbits admin privileges. The + * `/all` endpoint is `check_admin`-gated, so a 200 means "admin", + * any other response means "not admin". + */ + async isAdmin(adminKey: string): Promise { + try { + await this.request('/events/api/v1/events/all', { + method: 'GET', + headers: { 'X-API-KEY': adminKey }, + }) + return true + } catch { + return false + } + } + + /** + * Read the extension's auto_approve flag. Admin-only endpoint, so + * non-admin callers see false (the safe default for UI gating). + */ + async getAutoApprove(adminKey: string): Promise { + try { + const settings = await this.request('/events/api/v1/events/settings', { + method: 'GET', + headers: { 'X-API-KEY': adminKey }, + }) + return Boolean(settings?.auto_approve) + } catch { + return false + } + } + /** * Fetch available currencies from LNbits. */