mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 15:53:02 +10:00
feat: add sending pending email queue
This commit is contained in:
@ -8,9 +8,9 @@ import { DocumentStatus, SigningStatus } from '@documenso/prisma/client';
|
||||
import { WebhookTriggerEvents } from '@documenso/prisma/client';
|
||||
|
||||
import type { TRecipientActionAuth } from '../../types/document-auth';
|
||||
import { queueJob } from '../queue/job';
|
||||
import { triggerWebhook } from '../webhooks/trigger/trigger-webhook';
|
||||
import { sealDocument } from './seal-document';
|
||||
import { sendPendingEmail } from './send-pending-email';
|
||||
|
||||
export type CompleteDocumentWithTokenOptions = {
|
||||
token: string;
|
||||
@ -134,7 +134,13 @@ export const completeDocumentWithToken = async ({
|
||||
});
|
||||
|
||||
if (pendingRecipients > 0) {
|
||||
await sendPendingEmail({ documentId, recipientId: recipient.id });
|
||||
await queueJob({
|
||||
job: 'send-pending-email',
|
||||
args: {
|
||||
documentId: document.id,
|
||||
recipientId: recipient.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const documents = await prisma.document.updateMany({
|
||||
|
||||
@ -5,18 +5,26 @@ import {
|
||||
type SendDocumentOptions as SendCompletedDocumentOptions,
|
||||
sendCompletedEmail,
|
||||
} from '../document/send-completed-email';
|
||||
import { type SendPendingEmailOptions, sendPendingEmail } from '../document/send-pending-email';
|
||||
|
||||
type JobOptions = {
|
||||
'send-completed-email': SendCompletedDocumentOptions;
|
||||
'send-pending-email': SendPendingEmailOptions;
|
||||
};
|
||||
|
||||
export const jobHandlers: {
|
||||
[K in keyof JobOptions]: WorkHandler<JobOptions[K]>;
|
||||
} = {
|
||||
'send-completed-email': async ({ data }) => {
|
||||
'send-completed-email': async ({ data: { documentId, requestMetadata } }) => {
|
||||
await sendCompletedEmail({
|
||||
documentId: data.documentId,
|
||||
requestMetadata: data.requestMetadata,
|
||||
documentId,
|
||||
requestMetadata,
|
||||
});
|
||||
},
|
||||
'send-pending-email': async ({ data: { documentId, recipientId } }) => {
|
||||
await sendPendingEmail({
|
||||
documentId,
|
||||
recipientId,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user