mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
29 lines
551 B
TypeScript
29 lines
551 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
import { ReadStatus } from '@documenso/prisma/client';
|
|
|
|
export type ViewedDocumentOptions = {
|
|
token: string;
|
|
};
|
|
|
|
export const viewedDocument = async ({ token }: ViewedDocumentOptions) => {
|
|
const recipient = await prisma.recipient.findFirst({
|
|
where: {
|
|
token,
|
|
readStatus: ReadStatus.NOT_OPENED,
|
|
},
|
|
});
|
|
|
|
if (!recipient) {
|
|
return;
|
|
}
|
|
|
|
await prisma.recipient.update({
|
|
where: {
|
|
id: recipient.id,
|
|
},
|
|
data: {
|
|
readStatus: ReadStatus.OPENED,
|
|
},
|
|
});
|
|
};
|