mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 00:32:43 +10:00
feat: power signing mode
This commit is contained in:
43
packages/lib/server-only/user/get-next-inbox-document.ts
Normal file
43
packages/lib/server-only/user/get-next-inbox-document.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import { DocumentStatus, RecipientRole, SigningStatus } from '@prisma/client';
|
||||
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
type GetNextInboxDocumentOptions = {
|
||||
email: string | undefined;
|
||||
};
|
||||
|
||||
export const getNextInboxDocument = async ({ email }: GetNextInboxDocumentOptions) => {
|
||||
if (!email) {
|
||||
throw new Error('User is required');
|
||||
}
|
||||
|
||||
return await prisma.document.findFirst({
|
||||
where: {
|
||||
Recipient: {
|
||||
some: {
|
||||
email,
|
||||
signingStatus: SigningStatus.NOT_SIGNED,
|
||||
role: {
|
||||
not: RecipientRole.CC,
|
||||
},
|
||||
},
|
||||
},
|
||||
status: { not: DocumentStatus.DRAFT },
|
||||
deletedAt: null,
|
||||
},
|
||||
select: {
|
||||
createdAt: true,
|
||||
title: true,
|
||||
Recipient: {
|
||||
where: {
|
||||
email,
|
||||
},
|
||||
select: {
|
||||
token: true,
|
||||
},
|
||||
},
|
||||
documentMeta: true,
|
||||
},
|
||||
orderBy: [{ createdAt: 'asc' }],
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user