From c54e7f59a06a3c83033efdfb52b7ee20a67057b0 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Wed, 28 Aug 2024 12:01:29 +0700 Subject: [PATCH] Fixed welcome email being sent for Admin API creates ref https://linear.app/tryghost/issue/ONC-274 This fix is done at the endpoint layer, which isn't ideal, but has the smallest surface area for the change. I think we may want to move it up a layer though, despite the extra complications. If we move the check _into_ the MembersAPI class however, we start to run into issues with circular dependncies due to the mess that is our dependency injection approach with the Members service --- ghost/core/core/server/api/endpoints/members.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ghost/core/core/server/api/endpoints/members.js b/ghost/core/core/server/api/endpoints/members.js index e9d8fb2daf..a623de79ff 100644 --- a/ghost/core/core/server/api/endpoints/members.js +++ b/ghost/core/core/server/api/endpoints/members.js @@ -2,6 +2,7 @@ // as it is a getter and may change during runtime. const moment = require('moment-timezone'); const errors = require('@tryghost/errors'); +const logging = require('@tryghost/logging'); const models = require('../../models'); const membersService = require('../../services/members'); @@ -11,6 +12,7 @@ const _ = require('lodash'); const messages = { memberNotFound: 'Member not found.', + notSendingWelcomeEmail: 'Email verification required, welcome email is disabled', memberAlreadyExists: { message: 'Member already exists', context: 'Attempting to {action} member with existing email address.' @@ -115,6 +117,10 @@ const controller = { }, permissions: true, async query(frame) { + if (await membersService.verificationTrigger.checkVerificationRequired()) { + logging.warn(tpl(messages.notSendingWelcomeEmail)); + frame.options.send_email = false; + } const member = await membersService.api.memberBREADService.add(frame.data.members[0], frame.options); return member;