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 className="flex items-center justify-between gap-x-4">
|
||||||
<div>
|
<div>
|
||||||
<h4 className="text-lg font-semibold">Webhook URL</h4>
|
<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>
|
<h4 className="mt-4 text-lg font-semibold">Event triggers</h4>
|
||||||
{webhook.eventTriggers.map((trigger, index) => (
|
{webhook.eventTriggers.map((trigger, index) => (
|
||||||
<span key={index} className="text-muted-foreground flex flex-row items-center">
|
<span key={index} className="text-muted-foreground flex flex-row items-center">
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export const sealDocument = async ({
|
|||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
documentData: true,
|
documentData: true,
|
||||||
|
Recipient: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -182,6 +182,9 @@ export const sendDocument = async ({
|
|||||||
data: {
|
data: {
|
||||||
status: DocumentStatus.PENDING,
|
status: DocumentStatus.PENDING,
|
||||||
},
|
},
|
||||||
|
include: {
|
||||||
|
Recipient: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { ReadStatus } from '@documenso/prisma/client';
|
|||||||
import { WebhookTriggerEvents } from '@documenso/prisma/client';
|
import { WebhookTriggerEvents } from '@documenso/prisma/client';
|
||||||
|
|
||||||
import { triggerWebhook } from '../../universal/trigger-webhook';
|
import { triggerWebhook } from '../../universal/trigger-webhook';
|
||||||
import { getDocumentAndSenderByToken } from './get-document-by-token';
|
import { getDocumentAndRecipientByToken } from './get-document-by-token';
|
||||||
|
|
||||||
export type ViewedDocumentOptions = {
|
export type ViewedDocumentOptions = {
|
||||||
token: string;
|
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({
|
await triggerWebhook({
|
||||||
eventTrigger: WebhookTriggerEvents.DOCUMENT_OPENED,
|
eventTrigger: WebhookTriggerEvents.DOCUMENT_OPENED,
|
||||||
documentData: {
|
documentData: document,
|
||||||
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,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user