feat(webhooks): pass webhook secret to testTrigger (#12187)

This commit is contained in:
JA authored and GitHub committed 2023-11-22 14:17:50 -05:00
1 parent 1de05ebf3d
commit 7ee035c3a3
3 files changed
+8 -5

No files matched your search

@@ -10,7 +10,7 @@ type TestTriggerOptions = {
};
export const testTriggerHandler = async ({ ctx: _ctx, input }: TestTriggerOptions) => {
const { url, type, payloadTemplate = null } = input;
const { url, type, payloadTemplate = null, secret = null } = input;
const translation = await getTranslation("en", "common");
const language = {
locale: "en",
@@ -40,8 +40,8 @@ export const testTriggerHandler = async ({ ctx: _ctx, input }: TestTriggerOption
};
try {
const webhook = { subscriberUrl: url, payloadTemplate, appId: null, secret: null };
return await sendPayload(null, type, new Date().toISOString(), webhook, data);
const webhook = { subscriberUrl: url, appId: null, payloadTemplate };
return await sendPayload(secret, type, new Date().toISOString(), webhook, data);
} catch (_err) {
const error = getErrorFromUnknown(_err);
return {
@@ -4,6 +4,7 @@ import { webhookIdAndEventTypeIdSchema } from "./types";
export const ZTestTriggerInputSchema = webhookIdAndEventTypeIdSchema.extend({
url: z.string().url(),
secret: z.string().optional(),
type: z.string(),
payloadTemplate: z.string().optional().nullable(),
});