mirror of
https://github.com/documenso/documenso.git
synced 2026-08-25 15:52:29 +10:00
fix: add multi email transport system (#2942)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { encryptEmailTransportConfig } from '@documenso/lib/server-only/email/email-transport-config';
|
||||
import { generateDatabaseId } from '@documenso/lib/universal/id';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
import { adminProcedure } from '../../trpc';
|
||||
import {
|
||||
ZCreateEmailTransportRequestSchema,
|
||||
ZCreateEmailTransportResponseSchema,
|
||||
} from './create-email-transport.types';
|
||||
|
||||
export const createEmailTransportRoute = adminProcedure
|
||||
.input(ZCreateEmailTransportRequestSchema)
|
||||
.output(ZCreateEmailTransportResponseSchema)
|
||||
.mutation(async ({ input }) => {
|
||||
const { name, fromName, fromAddress, config } = input;
|
||||
|
||||
const transport = await prisma.emailTransport.create({
|
||||
data: {
|
||||
id: generateDatabaseId('email_transport'),
|
||||
name,
|
||||
type: config.type,
|
||||
fromName,
|
||||
fromAddress,
|
||||
config: encryptEmailTransportConfig(config),
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
return {
|
||||
id: transport.id,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user