fix: FORM_SUBMITTED webhook payload change and support for Team Webhooks with it (#10986)
This commit is contained in:
1 parent
8891641953
commit
41ef354c7b
10 files changed
+333
-140
No files matched your search
@@ -122,24 +122,37 @@ const sendPayload = async (
|
||||
});
|
||||
}
|
||||
|
||||
return _sendPayload(secretKey, triggerEvent, createdAt, webhook, body, contentType);
|
||||
return _sendPayload(secretKey, webhook, body, contentType);
|
||||
};
|
||||
|
||||
export const sendGenericWebhookPayload = async (
|
||||
secretKey: string | null,
|
||||
triggerEvent: string,
|
||||
createdAt: string,
|
||||
webhook: Pick<Webhook, "subscriberUrl" | "appId" | "payloadTemplate">,
|
||||
data: Record<string, unknown>
|
||||
) => {
|
||||
const body = JSON.stringify(data);
|
||||
return _sendPayload(secretKey, triggerEvent, createdAt, webhook, body, "application/json");
|
||||
export const sendGenericWebhookPayload = async ({
|
||||
secretKey,
|
||||
triggerEvent,
|
||||
createdAt,
|
||||
webhook,
|
||||
data,
|
||||
rootData,
|
||||
}: {
|
||||
secretKey: string | null;
|
||||
triggerEvent: string;
|
||||
createdAt: string;
|
||||
webhook: Pick<Webhook, "subscriberUrl" | "appId" | "payloadTemplate">;
|
||||
data: Record<string, unknown>;
|
||||
rootData?: Record<string, unknown>;
|
||||
}) => {
|
||||
const body = JSON.stringify({
|
||||
// Added rootData props first so that using the known(i.e. triggerEvent, createdAt, payload) properties in rootData doesn't override the known properties
|
||||
...rootData,
|
||||
triggerEvent: triggerEvent,
|
||||
createdAt: createdAt,
|
||||
payload: data,
|
||||
});
|
||||
|
||||
return _sendPayload(secretKey, webhook, body, "application/json");
|
||||
};
|
||||
|
||||
const _sendPayload = async (
|
||||
secretKey: string | null,
|
||||
triggerEvent: string,
|
||||
createdAt: string,
|
||||
webhook: Pick<Webhook, "subscriberUrl" | "appId" | "payloadTemplate">,
|
||||
body: string,
|
||||
contentType: "application/json" | "application/x-www-form-urlencoded"
|
||||
|
||||
@@ -63,8 +63,8 @@ function Component({ webhookId }: { webhookId: string }) {
|
||||
backButton
|
||||
/>
|
||||
<WebhookForm
|
||||
noRoutingFormTriggers={false}
|
||||
webhook={webhook}
|
||||
noRoutingFormTriggers={!!webhook.teamId}
|
||||
onSubmit={(values: WebhookFormSubmitData) => {
|
||||
if (
|
||||
subscriberUrlReserved({
|
||||
|
||||
@@ -81,9 +81,9 @@ const NewWebhookView = () => {
|
||||
backButton
|
||||
/>
|
||||
<WebhookForm
|
||||
noRoutingFormTriggers={false}
|
||||
onSubmit={onCreateWebhook}
|
||||
apps={installedApps?.items.map((app) => app.slug)}
|
||||
noRoutingFormTriggers={!!teamId}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user