From 7f33e2de0d0e0e1b4c2ff5d172f5d6c89e8dcd15 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Thu, 22 Aug 2024 01:02:31 +0800 Subject: [PATCH] feat: add tick trpc endpoint --- src/server/trpc/routers/workspace.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/server/trpc/routers/workspace.ts b/src/server/trpc/routers/workspace.ts index fa07946..a1587b8 100644 --- a/src/server/trpc/routers/workspace.ts +++ b/src/server/trpc/routers/workspace.ts @@ -17,7 +17,11 @@ import { OPENAPI_TAG } from '../../utils/const.js'; import { OpenApiMeta } from 'trpc-openapi'; import { getServerCount } from '../../model/serverStatus.js'; import { ROLES, slugRegex } from '@tianji/shared'; -import { createUserSelect, joinWorkspace } from '../../model/user.js'; +import { + createUserSelect, + joinWorkspace, + leaveWorkspace, +} from '../../model/user.js'; import { WorkspacesOnUsersModelSchema } from '../../prisma/zod/workspacesonusers.js'; export const workspaceRouter = router({ @@ -222,6 +226,25 @@ export const workspaceRouter = router({ throw new Error('Target user not existed'); } }), + tick: workspaceOwnerProcedure + .meta( + buildWorkspaceOpenapi({ + method: 'DELETE', + path: '/{workspaceId}/tick', + description: 'Administrator kicks a user out of a workspace.', + }) + ) + .input( + z.object({ + targetUserId: z.string(), + }) + ) + .output(z.void()) + .mutation(async ({ input }) => { + const { targetUserId, workspaceId } = input; + + leaveWorkspace(targetUserId, workspaceId); + }), getUserWorkspaceRole: publicProcedure .input( z.object({