mirror of
https://github.com/documenso/documenso.git
synced 2025-11-21 20:21:38 +10:00
35 lines
745 B
TypeScript
35 lines
745 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
export type DeclineTeamInvitationOptions = {
|
|
userId: string;
|
|
teamId: number;
|
|
};
|
|
|
|
export const declineTeamInvitation = async ({ userId, teamId }: DeclineTeamInvitationOptions) => {
|
|
await prisma.$transaction(
|
|
async (tx) => {
|
|
const user = await tx.user.findFirstOrThrow({
|
|
where: {
|
|
id: userId,
|
|
},
|
|
});
|
|
|
|
const teamMemberInvite = await tx.teamMemberInvite.findFirstOrThrow({
|
|
where: {
|
|
teamId,
|
|
email: user.email,
|
|
},
|
|
});
|
|
|
|
await tx.teamMemberInvite.delete({
|
|
where: {
|
|
id: teamMemberInvite.id,
|
|
},
|
|
});
|
|
|
|
// TODO: notify the team owner
|
|
},
|
|
{ timeout: 30_000 },
|
|
);
|
|
};
|