Files
sign/packages/lib/server-only/recipient/get-recipients-for-template.ts

39 lines
684 B
TypeScript
Raw Normal View History

2023-10-06 22:54:24 +00:00
import { prisma } from '@documenso/prisma';
export interface GetRecipientsForTemplateOptions {
templateId: number;
userId: number;
}
export const getRecipientsForTemplate = async ({
templateId,
userId,
}: GetRecipientsForTemplateOptions) => {
const recipients = await prisma.recipient.findMany({
where: {
templateId,
Template: {
2024-02-08 12:33:20 +11:00
OR: [
{
userId,
},
{
team: {
members: {
some: {
userId,
},
},
},
},
],
2023-10-06 22:54:24 +00:00
},
},
orderBy: {
id: 'asc',
},
});
return recipients;
};