Browse Source

fix(nocodb): show invite link even smtp not configured

pull/5349/head
Wing-Kam Wong 2 years ago
parent
commit
3df67a7f51
  1. 2
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts
  2. 8
      packages/nocodb/src/lib/meta/helpers/NcPluginMgrv2.ts
  3. 2
      packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts

2
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -2486,7 +2486,7 @@ class BaseModelSqlv2 {
formView, formView,
filteredColumns filteredColumns
); );
(await NcPluginMgrv2.emailAdapter())?.mailSend({ (await NcPluginMgrv2.emailAdapter(false))?.mailSend({
to: emails.join(','), to: emails.join(','),
subject: 'NocoDB Form', subject: 'NocoDB Form',
html: ejs.render(formSubmissionEmailTemplate, { html: ejs.render(formSubmissionEmailTemplate, {

8
packages/nocodb/src/lib/meta/helpers/NcPluginMgrv2.ts

@ -174,6 +174,7 @@ class NcPluginMgrv2 {
} }
public static async emailAdapter( public static async emailAdapter(
isUserInvite = true,
ncMeta = Noco.ncMeta ncMeta = Noco.ncMeta
): Promise<IEmailAdapter> { ): Promise<IEmailAdapter> {
const pluginData = await ncMeta.metaGet2(null, null, MetaTable.PLUGIN, { const pluginData = await ncMeta.metaGet2(null, null, MetaTable.PLUGIN, {
@ -181,7 +182,12 @@ class NcPluginMgrv2 {
active: true, active: true,
}); });
if (!pluginData) throw new Error('Plugin not configured / active'); if (!pluginData) {
// return null to show the invite link in UI
if (isUserInvite) return null;
// for webhooks, throw the error
throw new Error('Plugin not configured / active');
}
const pluginConfig = defaultPlugins.find( const pluginConfig = defaultPlugins.find(
(c) => c.title === pluginData.title && c.category === PluginCategory.EMAIL (c) => c.title === pluginData.title && c.category === PluginCategory.EMAIL

2
packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts

@ -302,7 +302,7 @@ export async function invokeWebhook(
case 'Email': case 'Email':
{ {
const res = await ( const res = await (
await NcPluginMgrv2.emailAdapter() await NcPluginMgrv2.emailAdapter(false)
)?.mailSend({ )?.mailSend({
to: parseBody(notification?.payload?.to, newData), to: parseBody(notification?.payload?.to, newData),
subject: parseBody(notification?.payload?.subject, newData), subject: parseBody(notification?.payload?.subject, newData),

Loading…
Cancel
Save