mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
This PR is handles the changes required to support envelopes. The new envelope editor/signing page will be hidden during release. The core changes here is to migrate the documents and templates model to a centralized envelopes model. Even though Documents and Templates are removed, from the user perspective they will still exist as we remap envelopes to documents and templates.
50 lines
916 B
TypeScript
50 lines
916 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
export type GetRecipientOrSenderByShareLinkSlugOptions = {
|
|
slug: string;
|
|
};
|
|
|
|
export const getRecipientOrSenderByShareLinkSlug = async ({
|
|
slug,
|
|
}: GetRecipientOrSenderByShareLinkSlugOptions) => {
|
|
const { envelopeId, email } = await prisma.documentShareLink.findFirstOrThrow({
|
|
where: {
|
|
slug,
|
|
},
|
|
});
|
|
|
|
const sender = await prisma.user.findFirst({
|
|
where: {
|
|
envelopes: { some: { id: envelopeId } },
|
|
email,
|
|
},
|
|
select: {
|
|
email: true,
|
|
name: true,
|
|
signature: true,
|
|
},
|
|
});
|
|
|
|
if (sender) {
|
|
return sender;
|
|
}
|
|
|
|
const recipient = await prisma.recipient.findFirst({
|
|
where: {
|
|
envelopeId,
|
|
email,
|
|
},
|
|
select: {
|
|
email: true,
|
|
name: true,
|
|
signatures: true,
|
|
},
|
|
});
|
|
|
|
if (recipient) {
|
|
return recipient;
|
|
}
|
|
|
|
throw new Error('Recipient or sender not found');
|
|
};
|