From bec52ac6c2bed0c76761fa090a3ef7b5e776e2a9 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 19 Apr 2022 16:55:51 +0800 Subject: [PATCH] refactor: show useful message when no email plugin is configured Signed-off-by: Wing-Kam Wong --- .../src/lib/noco/meta/api/projectUserApis.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts b/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts index a6f299cda3..6e4423f08d 100644 --- a/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts +++ b/packages/nocodb/src/lib/noco/meta/api/projectUserApis.ts @@ -9,10 +9,11 @@ import User from '../../../noco-models/User'; import { Tele } from 'nc-help'; import Audit from '../../../noco-models/Audit'; import NocoCache from '../../../noco-cache/NocoCache'; -import { CacheGetType, CacheScope } from '../../../utils/globals'; +import { CacheGetType, CacheScope, MetaTable } from '../../../utils/globals'; import * as ejs from 'ejs'; import NcPluginMgrv2 from '../helpers/NcPluginMgrv2'; import Noco from '../../Noco'; +import { PluginCategory } from 'nocodb-sdk'; async function userList(req, res) { res.json({ @@ -230,6 +231,17 @@ async function projectUserInviteResend(req, res): Promise { invite_token_expires: new Date(Date.now() + 24 * 60 * 60 * 1000) }); + const pluginData = await Noco.ncMeta.metaGet2(null, null, MetaTable.PLUGIN, { + category: PluginCategory.EMAIL, + active: true + }); + + if (!pluginData) { + NcError.badRequest( + `No Email Plugin is found. Please go to App Store to configure first or copy the invitation URL to users instead.` + ); + } + await sendInviteEmail(user.email, invite_token, req); Audit.insert({