mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
feat: updated the triggerWebhook function
This commit is contained in:
@ -47,7 +47,7 @@ export default function WebhookPage() {
|
||||
<div className="flex items-center justify-between gap-x-4">
|
||||
<div>
|
||||
<h4 className="text-lg font-semibold">Webhook URL</h4>
|
||||
<p className="text-muted-foreground">{webhook.webhookUrl}</p>
|
||||
<p className="text-muted-foreground break-all">{webhook.webhookUrl}</p>
|
||||
<h4 className="mt-4 text-lg font-semibold">Event triggers</h4>
|
||||
{webhook.eventTriggers.map((trigger, index) => (
|
||||
<span key={index} className="text-muted-foreground flex flex-row items-center">
|
||||
|
||||
@ -38,6 +38,7 @@ export const sealDocument = async ({
|
||||
},
|
||||
include: {
|
||||
documentData: true,
|
||||
Recipient: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -182,6 +182,9 @@ export const sendDocument = async ({
|
||||
data: {
|
||||
status: DocumentStatus.PENDING,
|
||||
},
|
||||
include: {
|
||||
Recipient: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ import { ReadStatus } from '@documenso/prisma/client';
|
||||
import { WebhookTriggerEvents } from '@documenso/prisma/client';
|
||||
|
||||
import { triggerWebhook } from '../../universal/trigger-webhook';
|
||||
import { getDocumentAndSenderByToken } from './get-document-by-token';
|
||||
import { getDocumentAndRecipientByToken } from './get-document-by-token';
|
||||
|
||||
export type ViewedDocumentOptions = {
|
||||
token: string;
|
||||
@ -56,21 +56,10 @@ export const viewedDocument = async ({ token, requestMetadata }: ViewedDocumentO
|
||||
});
|
||||
});
|
||||
|
||||
const document = await getDocumentAndSenderByToken({ token });
|
||||
const document = await getDocumentAndRecipientByToken({ token });
|
||||
|
||||
await triggerWebhook({
|
||||
eventTrigger: WebhookTriggerEvents.DOCUMENT_OPENED,
|
||||
documentData: {
|
||||
id: document.id,
|
||||
userId: document.userId,
|
||||
title: document.title,
|
||||
status: document.status,
|
||||
documentDataId: document.documentDataId,
|
||||
createdAt: document.createdAt,
|
||||
updatedAt: document.updatedAt,
|
||||
completedAt: document.completedAt,
|
||||
deletedAt: document.deletedAt,
|
||||
teamId: document.teamId,
|
||||
},
|
||||
documentData: document,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user