Add join token TTL policy and Live Show link sharing
This commit is contained in:
@@ -72,6 +72,13 @@ export type LiveShowSettings = {
|
||||
background_mode?: 'blur_last' | 'gradient' | 'solid' | 'brand';
|
||||
};
|
||||
|
||||
export type LiveShowLink = {
|
||||
token: string;
|
||||
url: string;
|
||||
qr_code_data_url: string | null;
|
||||
rotated_at: string | null;
|
||||
};
|
||||
|
||||
export type TenantEvent = {
|
||||
id: number;
|
||||
name: string | Record<string, string>;
|
||||
@@ -1521,6 +1528,42 @@ export type GetLiveShowQueueOptions = {
|
||||
liveStatus?: LiveShowQueueStatus;
|
||||
};
|
||||
|
||||
function normalizeLiveShowLink(payload: JsonValue | LiveShowLink | null | undefined): LiveShowLink {
|
||||
if (!payload || typeof payload !== 'object') {
|
||||
return {
|
||||
token: '',
|
||||
url: '',
|
||||
qr_code_data_url: null,
|
||||
rotated_at: null,
|
||||
};
|
||||
}
|
||||
|
||||
const record = payload as Record<string, JsonValue>;
|
||||
|
||||
return {
|
||||
token: typeof record.token === 'string' ? record.token : '',
|
||||
url: typeof record.url === 'string' ? record.url : '',
|
||||
qr_code_data_url: typeof record.qr_code_data_url === 'string' ? record.qr_code_data_url : null,
|
||||
rotated_at: typeof record.rotated_at === 'string' ? record.rotated_at : null,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getLiveShowLink(slug: string): Promise<LiveShowLink> {
|
||||
const response = await authorizedFetch(`${eventEndpoint(slug)}/live-show/link`);
|
||||
const data = await jsonOrThrow<{ data?: JsonValue }>(response, 'Failed to load live show link');
|
||||
|
||||
return normalizeLiveShowLink(data.data);
|
||||
}
|
||||
|
||||
export async function rotateLiveShowLink(slug: string): Promise<LiveShowLink> {
|
||||
const response = await authorizedFetch(`${eventEndpoint(slug)}/live-show/link/rotate`, {
|
||||
method: 'POST',
|
||||
});
|
||||
const data = await jsonOrThrow<{ data?: JsonValue }>(response, 'Failed to rotate live show link');
|
||||
|
||||
return normalizeLiveShowLink(data.data);
|
||||
}
|
||||
|
||||
export async function getEventPhotos(
|
||||
slug: string,
|
||||
options: GetEventPhotosOptions = {}
|
||||
|
||||
Reference in New Issue
Block a user