Webhook polishing (#2987)

This commit is contained in:
Syed Ali Shahbaz authored and GitHub committed 2022-06-16 17:21:48 +01:00
1 parent c5a40f6c37
commit 6253216484
13 files changed
+149 -11

No files matched your search

+4 -4
View File
@@ -97,6 +97,7 @@ export const webhookRouter = createProtectedRouter()
payloadTemplate: z.string().nullable(),
eventTypeId: z.number().optional(),
appId: z.string().optional().nullable(),
secret: z.string().optional().nullable(),
}),
async resolve({ ctx, input }) {
if (input.eventTypeId) {
@@ -125,6 +126,7 @@ export const webhookRouter = createProtectedRouter()
payloadTemplate: z.string().nullable(),
eventTypeId: z.number().optional(),
appId: z.string().optional().nullable(),
secret: z.string().optional().nullable(),
}),
async resolve({ ctx, input }) {
const { id, ...data } = input;
@@ -161,7 +163,6 @@ export const webhookRouter = createProtectedRouter()
}),
async resolve({ ctx, input }) {
const { id } = input;
input.eventTypeId
? await ctx.prisma.eventType.update({
where: {
@@ -207,7 +208,6 @@ export const webhookRouter = createProtectedRouter()
};
const data = {
triggerEvent: "PING",
type: "Test",
title: "Test trigger event",
description: "",
@@ -230,8 +230,8 @@ export const webhookRouter = createProtectedRouter()
};
try {
const webhook = { subscriberUrl: url, payloadTemplate, appId: null };
return await sendPayload(type, new Date().toISOString(), webhook, data);
const webhook = { subscriberUrl: url, payloadTemplate, appId: null, secret: null };
return await sendPayload(null, type, new Date().toISOString(), webhook, data);
} catch (_err) {
const error = getErrorFromUnknown(_err);
return {