8130 creating a new company in twenty doesnt activate on zapier (#8166)
- fix webhook.operation format change from august 2024 not spread in twenty-zapier - added a comment so it does not happen again - add a fix for the new webhook.operations column that would produce another issue
This commit is contained in:
@ -11,6 +11,7 @@ export enum Operation {
|
||||
create = 'create',
|
||||
update = 'update',
|
||||
delete = 'delete',
|
||||
destroy = 'destroy',
|
||||
}
|
||||
|
||||
export const subscribe = async (
|
||||
@ -18,18 +19,36 @@ export const subscribe = async (
|
||||
bundle: Bundle,
|
||||
operation: Operation,
|
||||
) => {
|
||||
const data = {
|
||||
targetUrl: bundle.targetUrl,
|
||||
operation: `${operation}.${bundle.inputData.nameSingular}`,
|
||||
};
|
||||
const result = await requestDb(
|
||||
z,
|
||||
bundle,
|
||||
`mutation createWebhook {createWebhook(data:{${handleQueryParams(
|
||||
data,
|
||||
)}}) {id}}`,
|
||||
);
|
||||
return result.data.createWebhook;
|
||||
try {
|
||||
const data = {
|
||||
targetUrl: bundle.targetUrl,
|
||||
operations: [`${bundle.inputData.nameSingular}.${operation}`],
|
||||
};
|
||||
const result = await requestDb(
|
||||
z,
|
||||
bundle,
|
||||
`mutation createWebhook {createWebhook(data:{${handleQueryParams(
|
||||
data,
|
||||
)}}) {id}}`,
|
||||
);
|
||||
return result.data.createWebhook;
|
||||
} catch (e) {
|
||||
// Remove that catch code when VERSION 0.32 is deployed
|
||||
// probably removable after 01/11/2024
|
||||
// (ie: when operations column exists in all active workspace schemas)
|
||||
const data = {
|
||||
targetUrl: bundle.targetUrl,
|
||||
operation: `${bundle.inputData.nameSingular}.${operation}`,
|
||||
};
|
||||
const result = await requestDb(
|
||||
z,
|
||||
bundle,
|
||||
`mutation createWebhook {createWebhook(data:{${handleQueryParams(
|
||||
data,
|
||||
)}}) {id}}`,
|
||||
);
|
||||
return result.data.createWebhook;
|
||||
}
|
||||
};
|
||||
|
||||
export const performUnsubscribe = async (z: ZObject, bundle: Bundle) => {
|
||||
|
||||
Reference in New Issue
Block a user