Browse Source

feat: allow handlebar syntax in hooks payload

re #792

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/805/head
Pranav C 3 years ago
parent
commit
0c13680c58
  1. 14
      packages/nocodb/src/lib/noco/common/BaseModel.ts
  2. 24
      packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

14
packages/nocodb/src/lib/noco/common/BaseModel.ts

@ -184,7 +184,19 @@ class BaseModel<T extends BaseApiBuilder<any>> extends BaseModelSql {
data, data,
hook.notification?.payload hook.notification?.payload
), ),
hook.notification?.payload JSON.parse(
JSON.stringify(hook.notification?.payload),
(_key, value) => {
return typeof value === 'string'
? this.parseBody(
value,
req,
data,
hook.notification?.payload
)
: value;
}
)
); );
} }
break; break;

24
packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

@ -31,7 +31,7 @@ import { GqlApiBuilder } from '../gql/GqlApiBuilder';
import NcPluginMgr from '../plugins/NcPluginMgr'; import NcPluginMgr from '../plugins/NcPluginMgr';
import XcCache from '../plugins/adapters/cache/XcCache'; import XcCache from '../plugins/adapters/cache/XcCache';
import EmailFactory from '../plugins/adapters/email/EmailFactory'; import EmailFactory from '../plugins/adapters/email/EmailFactory';
import Twilio from '../plugins/adapters/twilio/Twilio'; // import Twilio from '../plugins/adapters/twilio/Twilio';
import { RestApiBuilder } from '../rest/RestApiBuilder'; import { RestApiBuilder } from '../rest/RestApiBuilder';
import RestAuthCtrl from '../rest/RestAuthCtrlEE'; import RestAuthCtrl from '../rest/RestAuthCtrlEE';
import { packageVersion } from 'nc-help'; import { packageVersion } from 'nc-help';
@ -48,7 +48,7 @@ export default class NcMetaMgr {
public projectConfigs = {}; public projectConfigs = {};
public readonly pluginMgr: NcPluginMgr; public readonly pluginMgr: NcPluginMgr;
public twilioInstance: Twilio; // public twilioInstance: Twilio;
protected app: Noco; protected app: Noco;
@ -75,7 +75,7 @@ export default class NcMetaMgr {
public async initHandler(rootRouter: Router) { public async initHandler(rootRouter: Router) {
await this.pluginMgr?.init(); await this.pluginMgr?.init();
await this.initTwilio(); // await this.initTwilio();
await this.initCache(); await this.initCache();
this.eeVerify(); this.eeVerify();
@ -1309,15 +1309,15 @@ export default class NcMetaMgr {
}; };
} }
protected async initTwilio(overwrite = false): Promise<void> { // protected async initTwilio(overwrite = false): Promise<void> {
const activeStorage = await this.xcMeta.metaGet(null, null, 'nc_plugins', { // // const activeStorage = await this.xcMeta.metaGet(null, null, 'nc_plugins', {
active: true, // // active: true,
category: 'Twilio' // // category: 'Twilio'
}); // // });
// //
this.twilioInstance = Twilio.create(activeStorage, overwrite); // // this.twilioInstance = Twilio.create(activeStorage, overwrite);
await this.twilioInstance?.init(); // // await this.twilioInstance?.init();
} // }
protected async initCache(overwrite = false): Promise<void> { protected async initCache(overwrite = false): Promise<void> {
const activeCache = await this.xcMeta.metaGet(null, null, 'nc_plugins', { const activeCache = await this.xcMeta.metaGet(null, null, 'nc_plugins', {

Loading…
Cancel
Save