Support Mitra notification subtype

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-09-14 17:04:31 +02:00
parent 6b7082f8fe
commit 6b6b9cc40a
6 changed files with 26 additions and 12 deletions

View File

@ -24,8 +24,14 @@ const accountNotificationSchema = baseNotificationSchema.extend({
type: z.enum(['follow', 'follow_request', 'admin.sign_up', 'bite']),
});
const mentionNotificationSchema = baseNotificationSchema.extend({
type: z.literal('mention'),
subtype: z.enum(['reply']).nullable().catch(null),
status: statusSchema,
});
const statusNotificationSchema = baseNotificationSchema.extend({
type: z.enum(['mention', 'status', 'reblog', 'favourite', 'poll', 'update', 'event_reminder']),
type: z.enum(['status', 'reblog', 'favourite', 'poll', 'update', 'event_reminder']),
status: statusSchema,
});
@ -77,6 +83,7 @@ const notificationSchema: z.ZodType<Notification> = z.preprocess((notification:
: notification.type?.replace(/^pleroma:/, ''),
}), z.discriminatedUnion('type', [
accountNotificationSchema,
mentionNotificationSchema,
statusNotificationSchema,
reportNotificationSchema,
severedRelationshipNotificationSchema,
@ -89,6 +96,7 @@ const notificationSchema: z.ZodType<Notification> = z.preprocess((notification:
type Notification = z.infer<
| typeof accountNotificationSchema
| typeof mentionNotificationSchema
| typeof statusNotificationSchema
| typeof reportNotificationSchema
| typeof severedRelationshipNotificationSchema

View File

@ -1,6 +1,6 @@
{
"name": "pl-api",
"version": "0.0.31",
"version": "0.0.32",
"type": "module",
"homepage": "https://github.com/mkljczk/pl-fe/tree/fork/packages/pl-api",
"repository": {