Browse Source

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

pull/5349/head
Wing-Kam Wong 1 year 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,
filteredColumns
);
(await NcPluginMgrv2.emailAdapter())?.mailSend({
(await NcPluginMgrv2.emailAdapter(false))?.mailSend({
to: emails.join(','),
subject: 'NocoDB Form',
html: ejs.render(formSubmissionEmailTemplate, {

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

@ -174,6 +174,7 @@ class NcPluginMgrv2 {
}
public static async emailAdapter(
isUserInvite = true,
ncMeta = Noco.ncMeta
): Promise<IEmailAdapter> {
const pluginData = await ncMeta.metaGet2(null, null, MetaTable.PLUGIN, {
@ -181,7 +182,12 @@ class NcPluginMgrv2 {
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(
(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':
{
const res = await (
await NcPluginMgrv2.emailAdapter()
await NcPluginMgrv2.emailAdapter(false)
)?.mailSend({
to: parseBody(notification?.payload?.to, newData),
subject: parseBody(notification?.payload?.subject, newData),

Loading…
Cancel
Save