2023-09-22 12:27:54 +00:00
|
|
|
'use server';
|
|
|
|
|
|
|
|
|
|
import { prisma } from '@documenso/prisma';
|
|
|
|
|
|
|
|
|
|
export type CreateDocumentMetaOptions = {
|
|
|
|
|
documentId: number;
|
2024-01-12 20:54:59 +05:30
|
|
|
subject?: string;
|
|
|
|
|
message?: string;
|
|
|
|
|
timezone?: string;
|
2024-01-17 17:17:08 +11:00
|
|
|
password?: string;
|
2024-01-12 20:54:59 +05:30
|
|
|
dateFormat?: string;
|
2024-01-31 18:17:43 +05:30
|
|
|
redirectUrl?: string;
|
2024-01-03 20:10:50 +11:00
|
|
|
userId: number;
|
2023-09-22 12:27:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const upsertDocumentMeta = async ({
|
|
|
|
|
subject,
|
|
|
|
|
message,
|
2023-12-26 23:50:40 +00:00
|
|
|
timezone,
|
|
|
|
|
dateFormat,
|
2023-09-22 12:27:54 +00:00
|
|
|
documentId,
|
2024-01-03 20:10:50 +11:00
|
|
|
userId,
|
2024-01-17 17:17:08 +11:00
|
|
|
password,
|
2024-01-31 18:17:43 +05:30
|
|
|
redirectUrl,
|
2023-09-22 12:27:54 +00:00
|
|
|
}: CreateDocumentMetaOptions) => {
|
2024-01-03 20:10:50 +11:00
|
|
|
await prisma.document.findFirstOrThrow({
|
|
|
|
|
where: {
|
|
|
|
|
id: documentId,
|
2024-02-06 16:16:10 +11:00
|
|
|
OR: [
|
|
|
|
|
{
|
|
|
|
|
userId,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
team: {
|
|
|
|
|
members: {
|
|
|
|
|
some: {
|
|
|
|
|
userId,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
2024-01-03 20:10:50 +11:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2023-09-22 12:27:54 +00:00
|
|
|
return await prisma.documentMeta.upsert({
|
|
|
|
|
where: {
|
|
|
|
|
documentId,
|
|
|
|
|
},
|
|
|
|
|
create: {
|
|
|
|
|
subject,
|
|
|
|
|
message,
|
2024-01-31 18:17:43 +05:30
|
|
|
password,
|
2023-12-26 23:50:40 +00:00
|
|
|
dateFormat,
|
|
|
|
|
timezone,
|
2023-09-22 12:27:54 +00:00
|
|
|
documentId,
|
2024-01-31 18:17:43 +05:30
|
|
|
redirectUrl,
|
2023-09-22 12:27:54 +00:00
|
|
|
},
|
|
|
|
|
update: {
|
|
|
|
|
subject,
|
|
|
|
|
message,
|
2024-01-17 17:17:08 +11:00
|
|
|
password,
|
2024-01-31 18:17:43 +05:30
|
|
|
dateFormat,
|
2023-12-26 23:50:40 +00:00
|
|
|
timezone,
|
2024-01-31 18:17:43 +05:30
|
|
|
redirectUrl,
|
2023-09-22 12:27:54 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
};
|