feat(P5A.T2): WatchTogetherPayload + wrappers + parseYouTubeUrl + tests
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user