mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
fix: update email template and tidy code
This commit is contained in:
@ -9,6 +9,7 @@ import { superDeleteDocument } from '@documenso/lib/server-only/document/super-d
|
||||
import { upsertSiteSetting } from '@documenso/lib/server-only/site-settings/upsert-site-setting';
|
||||
import { deleteUser } from '@documenso/lib/server-only/user/delete-user';
|
||||
import { getUserById } from '@documenso/lib/server-only/user/get-user-by-id';
|
||||
import { extractNextApiRequestMetadata } from '@documenso/lib/universal/extract-request-metadata';
|
||||
|
||||
import { adminProcedure, router } from '../trpc';
|
||||
import {
|
||||
@ -121,15 +122,21 @@ export const adminRouter = router({
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
||||
deleteDocument: adminProcedure
|
||||
.input(ZAdminDeleteDocumentMutationSchema)
|
||||
.mutation(async ({ input }) => {
|
||||
const { id, userId, reason } = input;
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const { id, reason } = input;
|
||||
try {
|
||||
await sendDeleteEmail({ documentId: id, reason });
|
||||
return await superDeleteDocument({ id, userId });
|
||||
|
||||
return await superDeleteDocument({
|
||||
id,
|
||||
requestMetadata: extractNextApiRequestMetadata(ctx.req),
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
message: 'We were unable to delete the specified document. Please try again.',
|
||||
|
||||
@ -51,7 +51,6 @@ export type TAdminDeleteUserMutationSchema = z.infer<typeof ZAdminDeleteUserMuta
|
||||
|
||||
export const ZAdminDeleteDocumentMutationSchema = z.object({
|
||||
id: z.number().min(1),
|
||||
userId: z.number(),
|
||||
reason: z.string(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user