feat(P5A.T2): WatchTogetherPayload + wrappers + parseYouTubeUrl + tests

This commit is contained in:
byGalax
2026-05-16 21:21:30 +02:00
parent ad239ec549
commit 4399d39f08
5 changed files with 298 additions and 1 deletions
+19 -1
View File
@@ -82,11 +82,18 @@ export interface WhiteboardPayload {
whiteboard_id: string;
}
export interface WatchTogetherPayload {
v: 1;
type: 'watch_together';
session_id: string;
}
export type MessagePayload =
| TextMessagePayload
| CallEventPayload
| PollPayload
| WhiteboardPayload;
| WhiteboardPayload
| WatchTogetherPayload;
export type ParsedMessagePayload =
| {
@@ -109,6 +116,10 @@ export type ParsedMessagePayload =
| {
kind: 'whiteboard';
whiteboardId: string;
}
| {
kind: 'watch_together';
sessionId: string;
};
export function serializeMessagePayload(payload: MessagePayload): string {
@@ -172,6 +183,13 @@ export function parseMessagePayload(raw: string | null): ParsedMessagePayload {
: '';
return { kind: 'whiteboard', whiteboardId: id };
}
if (obj.type === 'watch_together') {
const p = obj as Partial<WatchTogetherPayload>;
const id = typeof p.session_id === 'string' && p.session_id.length > 0
? p.session_id
: '';
return { kind: 'watch_together', sessionId: id };
}
const t = obj as TextMessagePayload;
return {
kind: 'text',