Browse Source

fix(nocodb): prevent saving bulk operation for v1 hooks

pull/5349/head
Wing-Kam Wong 2 years ago
parent
commit
9480952e19
  1. 11
      packages/nocodb/src/lib/models/Hook.ts

11
packages/nocodb/src/lib/models/Hook.ts

@ -7,6 +7,7 @@ import {
import Noco from '../Noco';
import NocoCache from '../cache/NocoCache';
import { extractProps } from '../meta/helpers/extractProps';
import { NcError } from '../meta/helpers/catchError';
import Model from './Model';
import Filter from './Filter';
import HookFilter from './HookFilter';
@ -187,8 +188,18 @@ export default class Hook implements HookType {
'retry_interval',
'timeout',
'active',
'version',
]);
if (
updateObj.version &&
updateObj.operation &&
updateObj.version === 'v1' &&
['bulkInsert', 'bulkUpdate', 'bulkDelete'].includes(updateObj.operation)
) {
NcError.badRequest(`${updateObj.operation} not supported in v1 hook`);
}
if (updateObj.notification && typeof updateObj.notification === 'object') {
updateObj.notification = JSON.stringify(updateObj.notification);
}

Loading…
Cancel
Save