mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
39 lines
684 B
TypeScript
39 lines
684 B
TypeScript
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: {
|
|
OR: [
|
|
{
|
|
userId,
|
|
},
|
|
{
|
|
team: {
|
|
members: {
|
|
some: {
|
|
userId,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
orderBy: {
|
|
id: 'asc',
|
|
},
|
|
});
|
|
|
|
return recipients;
|
|
};
|