From 39863bc94f4e84087bc336bf1e3d22d95370f2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 1 Sep 2024 17:28:16 +0200 Subject: [PATCH] pl-api: Support marker streaming event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- packages/pl-api/lib/entities/streaming-event.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/pl-api/lib/entities/streaming-event.ts b/packages/pl-api/lib/entities/streaming-event.ts index f89307467..917f4a6d1 100644 --- a/packages/pl-api/lib/entities/streaming-event.ts +++ b/packages/pl-api/lib/entities/streaming-event.ts @@ -4,6 +4,7 @@ import { announcementSchema } from './announcement'; import { announcementReactionSchema } from './announcement-reaction'; import { chatSchema } from './chat'; import { conversationSchema } from './conversation'; +import { markerSchema } from './marker'; import { notificationSchema } from './notification'; import { statusSchema } from './status'; @@ -79,6 +80,11 @@ const respondStreamingEventSchema = baseStreamingEventSchema.extend({ })), }); +const markerStreamingEventSchema = baseStreamingEventSchema.extend({ + event: z.literal('marker'), + payload: z.preprocess((payload: any) => JSON.parse(payload), markerSchema), +}); + /** @see {@link https://docs.joinmastodon.org/methods/streaming/#events} */ const streamingEventSchema: z.ZodType = z.preprocess((event: any) => ({ ...event, @@ -94,6 +100,7 @@ const streamingEventSchema: z.ZodType = z.preprocess((event: any chatUpdateStreamingEventSchema, followRelationshipsUpdateStreamingEventSchema, respondStreamingEventSchema, + markerStreamingEventSchema, ])) as any; type StreamingEvent = z.infer< @@ -107,6 +114,7 @@ type StreamingEvent = z.infer< | typeof chatUpdateStreamingEventSchema | typeof followRelationshipsUpdateStreamingEventSchema | typeof respondStreamingEventSchema +| typeof markerStreamingEventSchema >; export {