revert(api): 🔥 Use Notification's schema declaration instead of declaring it again every time

This commit is contained in:
Jesse Wierzbinski 2024-11-04 14:35:27 +01:00
parent 8765a45240
commit ca31830fb3
No known key found for this signature in database
2 changed files with 4 additions and 43 deletions

View file

@ -1,6 +1,6 @@
import { apiRoute, applyConfig, auth } from "@/api"; import { apiRoute, applyConfig, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi"; import { createRoute } from "@hono/zod-openapi";
import { Note, Notification, User } from "@versia/kit/db"; import { Notification } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables"; import { RolePermissions } from "@versia/kit/tables";
import { z } from "zod"; import { z } from "zod";
import { ErrorSchema } from "~/types/api"; import { ErrorSchema } from "~/types/api";
@ -37,36 +37,7 @@ const route = createRoute({
responses: { responses: {
200: { 200: {
description: "Notification", description: "Notification",
schema: z.object({ schema: Notification.schema,
account: z.lazy(() => User.schema).nullable(),
created_at: z.string(),
id: z.string().uuid(),
status: z.lazy(() => Note.schema).optional(),
// TODO: Add reactions
type: z.enum([
"mention",
"status",
"follow",
"follow_request",
"reblog",
"poll",
"favourite",
"update",
"admin.sign_up",
"admin.report",
"chat",
"pleroma:chat_mention",
"pleroma:emoji_reaction",
"pleroma:event_reminder",
"pleroma:participation_request",
"pleroma:participation_accepted",
"move",
"group_reblog",
"group_favourite",
"user_approved",
]),
target: z.lazy(() => User.schema).optional(),
}),
}, },
401: { 401: {
description: "Unauthorized", description: "Unauthorized",

View file

@ -1,6 +1,6 @@
import { apiRoute, applyConfig, auth, idValidator } from "@/api"; import { apiRoute, applyConfig, auth, idValidator } from "@/api";
import { createRoute } from "@hono/zod-openapi"; import { createRoute } from "@hono/zod-openapi";
import { Note, Timeline, User } from "@versia/kit/db"; import { Notification, Timeline } from "@versia/kit/db";
import { Notifications, RolePermissions } from "@versia/kit/tables"; import { Notifications, RolePermissions } from "@versia/kit/tables";
import { and, eq, gt, gte, inArray, lt, not, sql } from "drizzle-orm"; import { and, eq, gt, gte, inArray, lt, not, sql } from "drizzle-orm";
import { z } from "zod"; import { z } from "zod";
@ -102,17 +102,7 @@ const route = createRoute({
description: "Notifications", description: "Notifications",
content: { content: {
"application/json": { "application/json": {
schema: z.array( schema: z.array(Notification.schema),
z.object({
account: z.lazy(() => User.schema).nullable(),
created_at: z.string(),
id: z.string().uuid(),
status: z.lazy(() => Note.schema).optional(),
// TODO: Add reactions
type: z.string(),
target: z.lazy(() => User.schema).optional(),
}),
),
}, },
}, },
}, },