Skip to content

Commit 1325e84

Browse files
feat: Reduce webhook response payload to status-only (calcom#25072)
* feat: reduce webhook payload * Update packages/trpc/server/routers/viewer/webhook/testTrigger.handler.ts Co-authored-by: Volnei Munhoz <volnei@cal.com> --------- Co-authored-by: Volnei Munhoz <volnei@cal.com>
1 parent d50a7b9 commit 1325e84

4 files changed

Lines changed: 9 additions & 12 deletions

File tree

packages/features/webhooks/components/WebhookTestDisclosure.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ export default function WebhookTestDisclosure() {
6969
</div>
7070
<div className="bg-muted border-subtle rounded-b-lg border border-t-0 p-4 font-mono text-[13px] leading-4">
7171
{!mutation.data && <p>{t("no_data_yet")}</p>}
72-
{mutation.status === "success" && (
73-
<div className="overflow-x-auto">{JSON.stringify(mutation.data, null, 4)}</div>
72+
{mutation.status === "success" && mutation.data && (
73+
<div className="space-y-2">
74+
<div>
75+
<span className="text-subtle">{t("status")}:</span> <span className="text-emphasis">{mutation.data.status}</span>
76+
</div>
77+
</div>
7478
)}
7579
</div>
7680
</div>

packages/features/webhooks/lib/handleWebhookScheduledTriggers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export async function handleWebhookScheduledTriggers(prisma: PrismaClient) {
6464
method: "POST",
6565
body: job.payload,
6666
headers,
67+
// Avoid following redirect
68+
redirect: "manual"
6769
}).catch((error) => {
6870
console.error(`Webhook trigger for subscriber url ${job.subscriberUrl} failed with error: ${error}`);
6971
})

packages/features/webhooks/lib/sendPayload.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,9 @@ const _sendPayload = async (
305305
body,
306306
});
307307

308-
const text = await response.text();
309-
310308
return {
311309
ok: response.ok,
312310
status: response.status,
313-
...(text
314-
? {
315-
message: text,
316-
}
317-
: {}),
318311
};
319312
};
320313

packages/trpc/server/routers/viewer/webhook/testTrigger.handler.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ export const testTriggerHandler = async ({ ctx: _ctx, input }: TestTriggerOption
4343
try {
4444
const webhook = { subscriberUrl: url, appId: null, payloadTemplate };
4545
return await sendPayload(secret, type, new Date().toISOString(), webhook, data);
46-
} catch (_err) {
47-
const error = getErrorFromUnknown(_err);
46+
} catch {
4847
return {
4948
ok: false,
5049
status: 500,
51-
message: error.message,
5250
};
5351
}
5452
};

0 commit comments

Comments
 (0)