From 29af8579aff9f0516140f767fdb60be8018c6ac1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 13 Oct 2024 00:24:51 -0500 Subject: [PATCH] Add web push schema --- src/schemas/web-push.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/schemas/web-push.ts diff --git a/src/schemas/web-push.ts b/src/schemas/web-push.ts new file mode 100644 index 000000000..9162f2bfb --- /dev/null +++ b/src/schemas/web-push.ts @@ -0,0 +1,24 @@ +import { z } from 'zod'; + +/** https://docs.joinmastodon.org/entities/WebPushSubscription/ */ +const webPushSubscriptionSchema = z.object({ + id: z.coerce.string(), + endpoint: z.string().url(), + alerts: z.object({ + mention: z.boolean().optional(), + status: z.boolean().optional(), + reblog: z.boolean().optional(), + follow: z.boolean().optional(), + follow_request: z.boolean().optional(), + favourite: z.boolean().optional(), + poll: z.boolean().optional(), + update: z.boolean().optional(), + 'admin.sign_up': z.boolean().optional(), + 'admin.report': z.boolean().optional(), + }).optional(), + server_key: z.string(), +}); + +type WebPushSubscription = z.infer; + +export { webPushSubscriptionSchema, WebPushSubscription }; \ No newline at end of file