mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(api): 🏷️ Begin porting all code over to new schemas
This commit is contained in:
parent
fda1167234
commit
bff1c5f734
32 changed files with 171 additions and 264 deletions
|
|
@ -1,5 +1,86 @@
|
|||
import { z } from "@hono/zod-openapi";
|
||||
import { PushSubscription } from "@versia/kit/db";
|
||||
import { Id } from "./common.ts";
|
||||
|
||||
export const WebPushSubscription = z
|
||||
.object({
|
||||
id: Id.openapi({
|
||||
example: "24eb1891-accc-43b4-b213-478e37d525b4",
|
||||
description: "The ID of the Web Push subscription in the database.",
|
||||
}),
|
||||
endpoint: z.string().url().openapi({
|
||||
example: "https://yourdomain.example/listener",
|
||||
description: "Where push alerts will be sent to.",
|
||||
}),
|
||||
alerts: z
|
||||
.object({
|
||||
mention: z.boolean().optional().openapi({
|
||||
example: true,
|
||||
description: "Receive mention notifications?",
|
||||
}),
|
||||
favourite: z.boolean().optional().openapi({
|
||||
example: true,
|
||||
description: "Receive favourite notifications?",
|
||||
}),
|
||||
reblog: z.boolean().optional().openapi({
|
||||
example: true,
|
||||
description: "Receive reblog notifications?",
|
||||
}),
|
||||
follow: z.boolean().optional().openapi({
|
||||
example: true,
|
||||
description: "Receive follow notifications?",
|
||||
}),
|
||||
poll: z.boolean().optional().openapi({
|
||||
example: false,
|
||||
description: "Receive poll notifications?",
|
||||
}),
|
||||
follow_request: z.boolean().optional().openapi({
|
||||
example: false,
|
||||
description: "Receive follow request notifications?",
|
||||
}),
|
||||
status: z.boolean().optional().openapi({
|
||||
example: false,
|
||||
description:
|
||||
"Receive new subscribed account notifications?",
|
||||
}),
|
||||
update: z.boolean().optional().openapi({
|
||||
example: false,
|
||||
description: "Receive status edited notifications?",
|
||||
}),
|
||||
"admin.sign_up": z.boolean().optional().openapi({
|
||||
example: false,
|
||||
description:
|
||||
"Receive new user signup notifications? Must have a role with the appropriate permissions.",
|
||||
}),
|
||||
"admin.report": z.boolean().optional().openapi({
|
||||
example: false,
|
||||
description:
|
||||
"Receive new report notifications? Must have a role with the appropriate permissions.",
|
||||
}),
|
||||
})
|
||||
.default({})
|
||||
.openapi({
|
||||
example: {
|
||||
mention: true,
|
||||
favourite: true,
|
||||
reblog: true,
|
||||
follow: true,
|
||||
poll: false,
|
||||
follow_request: false,
|
||||
status: false,
|
||||
update: false,
|
||||
"admin.sign_up": false,
|
||||
"admin.report": false,
|
||||
},
|
||||
description:
|
||||
"Which alerts should be delivered to the endpoint.",
|
||||
}),
|
||||
server_key: z.string().openapi({
|
||||
example:
|
||||
"BCk-QqERU0q-CfYZjcuB6lnyyOYfJ2AifKqfeGIm7Z-HiTU5T9eTG5GxVA0_OH5mMlI4UkkDTpaZwozy0TzdZ2M=",
|
||||
description: "The streaming server’s VAPID key.",
|
||||
}),
|
||||
})
|
||||
.openapi({});
|
||||
|
||||
export const WebPushSubscriptionInput = z
|
||||
.object({
|
||||
|
|
@ -33,7 +114,7 @@ export const WebPushSubscriptionInput = z
|
|||
}),
|
||||
data: z
|
||||
.object({
|
||||
alerts: PushSubscription.schema.shape.alerts,
|
||||
alerts: WebPushSubscription.shape.alerts,
|
||||
})
|
||||
.strict()
|
||||
.default({
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { z } from "@hono/zod-openapi";
|
||||
import type { Status as ApiNote } from "@versia/client/types";
|
||||
import { Media } from "@versia/kit/db";
|
||||
import { zBoolean } from "~/packages/config-manager/config.type.ts";
|
||||
import { Account } from "./account.ts";
|
||||
import { Attachment } from "./attachment.ts";
|
||||
import { PreviewCard } from "./card.ts";
|
||||
import { Id, iso631 } from "./common.ts";
|
||||
import { CustomEmoji } from "./emoji.ts";
|
||||
|
|
@ -223,7 +223,7 @@ export const Status = z.object({
|
|||
url: "https://docs.joinmastodon.org/entities/Status/#visibility",
|
||||
},
|
||||
}),
|
||||
media_attachments: z.array(Media.schema).openapi({
|
||||
media_attachments: z.array(Attachment).openapi({
|
||||
description: "Media that is attached to this status.",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/Status/#media_attachments",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue