mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 00:32:43 +10:00
feat: add email domains (#1895)
Implemented Email Domains which allows Platform/Enterprise customers to send emails to recipients using their custom emails.
This commit is contained in:
@ -0,0 +1,45 @@
|
||||
import { ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP } from '@documenso/lib/constants/organisations';
|
||||
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||
import { buildOrganisationWhereQuery } from '@documenso/lib/utils/organisations';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
import { authenticatedProcedure } from '../trpc';
|
||||
import {
|
||||
ZDeleteOrganisationEmailRequestSchema,
|
||||
ZDeleteOrganisationEmailResponseSchema,
|
||||
} from './delete-organisation-email.types';
|
||||
|
||||
export const deleteOrganisationEmailRoute = authenticatedProcedure
|
||||
.input(ZDeleteOrganisationEmailRequestSchema)
|
||||
.output(ZDeleteOrganisationEmailResponseSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
const { emailId } = input;
|
||||
const { user } = ctx;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
emailId,
|
||||
},
|
||||
});
|
||||
|
||||
const email = await prisma.organisationEmail.findFirst({
|
||||
where: {
|
||||
id: emailId,
|
||||
organisation: buildOrganisationWhereQuery({
|
||||
organisationId: undefined,
|
||||
userId: user.id,
|
||||
roles: ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP['MANAGE_ORGANISATION'],
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
if (!email) {
|
||||
throw new AppError(AppErrorCode.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
await prisma.organisationEmail.delete({
|
||||
where: {
|
||||
id: email.id,
|
||||
},
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user