From 5b126c89779aa2832c41e8f1d6217c2c37ae0266 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 20 Feb 2023 20:04:13 +0800 Subject: [PATCH] refactor(nocodb): json stringify if input is object only --- packages/nocodb/src/lib/models/Hook.ts | 6 ++---- packages/nocodb/src/lib/models/Plugin.ts | 7 ++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/nocodb/src/lib/models/Hook.ts b/packages/nocodb/src/lib/models/Hook.ts index a6c0f37a3c..7c32d09bbd 100644 --- a/packages/nocodb/src/lib/models/Hook.ts +++ b/packages/nocodb/src/lib/models/Hook.ts @@ -155,10 +155,8 @@ export default class Hook implements HookType { | 'update'; } - if (insertObj.notification) { - insertObj.notification && typeof insertObj.notification === 'object' - ? JSON.stringify(insertObj.notification) - : insertObj.notification; + if (insertObj.notification && typeof insertObj.notification === 'object') { + insertObj.notification = JSON.stringify(insertObj.notification); } if (!(hook.project_id && hook.base_id)) { diff --git a/packages/nocodb/src/lib/models/Plugin.ts b/packages/nocodb/src/lib/models/Plugin.ts index d53757af51..711feb700e 100644 --- a/packages/nocodb/src/lib/models/Plugin.ts +++ b/packages/nocodb/src/lib/models/Plugin.ts @@ -59,11 +59,8 @@ export default class Plugin implements PluginType { public static async update(pluginId: string, plugin: Partial) { const updateObj = extractProps(plugin, ['input', 'active']); - if (updateObj.input) { - updateObj.input = - updateObj.input && typeof updateObj.input === 'object' - ? JSON.stringify(updateObj.input) - : updateObj.input; + if (updateObj.input && typeof updateObj.input === 'object') { + updateObj.input = JSON.stringify(updateObj.input); } // get existing cache