Add Pretix ticketing integration (every-minute sidecar sync)

- docs/backend/pretix.md: Pretix REST API reference (auth, orders/items
  endpoints, pagination, rate limiting, worked example)
- migration 20260909000000_pretix_sync.sql: events.pretix_organizer +
  pretix_event_slug; _map_ticket_type, _ensure_auth_user (QR token =
  password), sync_pretix_attendees (service-role-only, idempotent)
- sidecar: pretixFetch/fetchPretixOrders/fetchPretixItems/transformPretix,
  runPretixSync + every-minute runPretixLoop, POST /run-pretix, /status
  extended with pretix state
- admin: Pretix panel + recent runs in Interfaces, per-event Pretix config
  + Sync button in Events, api/types for Pretix
- docker-compose: PRETIX_API_KEY / PRETIX_BASE / PRETIX_SYNC_INTERVAL_MS

Verified on VM: 25 paid orders -> 25 attendees, auto-sync every minute,
login via QR token works, idempotent (no duplicate registrations).

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-09-09 11:40:56 +02:00
1 parent d5ec009cb5
commit 509e342204
8 files changed
+1009 -10

No files matched your search

+11
View File
@@ -8,6 +8,7 @@ import type {
Feedback,
LeaderboardRow,
PointsLogRow,
PretixSyncResult,
Registration,
ResetQrResult,
Session,
@@ -152,6 +153,8 @@ export async function upsertEvent(
end_date: string;
location?: string | null;
sessionize_endpoint?: string | null;
pretix_organizer?: string | null;
pretix_event_slug?: string | null;
use_realtime_clock?: boolean;
},
): Promise<void> {
@@ -189,6 +192,10 @@ export const getSidecarStatus = () => sidecarFetch<SidecarStatus>('/status');
export const runSessionizeSync = (eventId: string) =>
sidecarFetch<SyncResult>('/run', { method: 'POST', body: JSON.stringify({ event_id: eventId }) });
/** Trigger a (blocking) Pretix sync for an event. Resolves with the result. */
export const runPretixSync = (eventId: string) =>
sidecarFetch<PretixSyncResult>('/run-pretix', { method: 'POST', body: JSON.stringify({ event_id: eventId }) });
/**
* Upload the Sessionize "Sessions and speakers (advanced)" .xlsx for an event.
* The sidecar parses it and imports speakers/sessions/agenda + speaker
@@ -216,6 +223,10 @@ export const getSyncRuns = (eventId: string) =>
rows.filter((r) => r.event_id === eventId),
);
/** Recent Pretix sync_runs rows for an event (newest first). */
export const getPretixRuns = (eventId: string) =>
getSyncRuns(eventId).then((rows) => rows.filter((r) => r.source === 'pretix'));
/** Set an event active (deactivates all others via trigger). */
export async function activateEvent(id: string): Promise<void> {
const { error } = await supabase.from('events').update({ is_active: true }).eq('id', id);
+34
View File
@@ -35,6 +35,10 @@ export interface Event {
use_realtime_clock: boolean;
/** Sessionize API URL for this event (e.g. .../api/v2/<id>/view/All). */
sessionize_endpoint: string | null;
/** Pretix organizer for this event (e.g. `appecommday`). */
pretix_organizer?: string | null;
/** Pretix event slug for this event (e.g. `tickets`). */
pretix_event_slug?: string | null;
/** When the Sessionize sync last ran for this event. */
last_synced_at: string | null;
avg_feedback: number | null;
@@ -108,11 +112,41 @@ export interface ExcelSyncResult {
error?: string;
}
/** The summary returned by the sync_pretix_attendees RPC. */
export interface PretixSyncSummary {
created: number;
updated: number;
skipped: number;
errors: string[];
}
/** The result of a (blocking) sidecar Pretix sync run. */
export interface PretixRun {
event_id: string;
event_name?: string;
started_at: string;
finished_at: string;
status: 'success' | 'error' | 'skipped';
reason?: string;
orders?: number;
attendees?: number;
skipped?: number;
summary?: PretixSyncSummary;
error?: string;
}
/** The response of POST /run-pretix (same shape as a successful PretixRun). */
export type PretixSyncResult = PretixRun;
/** The sidecar's /status response. */
export interface SidecarStatus {
ok: boolean;
running: boolean;
lastRun: SyncResult | null;
pretixRunning?: boolean;
lastPretixRun?: PretixRun | null;
pretixIntervalMs?: number;
pretixConfigured?: boolean;
}
export interface Registration {