0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Renamed trigger amount variable

refs https://github.com/TryGhost/Toolbox/issues/387

- Similar reasoning as to previous renames - the variables were named with a single trigger source in mind and now would be confusing with multiple verification trigger sources.
This commit is contained in:
Naz 2022-08-25 10:43:46 +08:00
parent 1e96ef849f
commit 7cae68baaa
3 changed files with 10 additions and 9 deletions

View file

@ -108,7 +108,7 @@ module.exports = {
apiTriggerThreshold: _.get(config.get('hostSettings'), 'emailVerification.importThreshold'),
isVerified: () => config.get('hostSettings:emailVerification:verified') === true,
isVerificationRequired: () => settingsCache.get('email_verification_required') === true,
sendVerificationEmail: ({subject, message, amountImported}) => {
sendVerificationEmail: ({subject, message, amountTriggered}) => {
const escalationAddress = config.get('hostSettings:emailVerification:escalationAddress');
const fromAddress = config.get('user_email');
@ -116,7 +116,7 @@ module.exports = {
ghostMailer.send({
subject,
html: tpl(message, {
importedNumber: amountImported,
amountTriggered: amountTriggered,
siteUrl: urlUtils.getSiteUrl()
}),
forceTextContent: true,

View file

@ -5,8 +5,8 @@ const {MemberSubscribeEvent} = require('@tryghost/member-events');
const messages = {
emailVerificationNeeded: `We're hard at work processing your import. To make sure you get great deliverability on a list of that size, we'll need to enable some extra features for your account. A member of our team will be in touch with you by email to review your account make sure everything is configured correctly so you're ready to go.`,
emailVerificationEmailSubject: `Email needs verification`,
emailVerificationEmailMessageImport: `Email verification needed for site: {siteUrl}, has imported: {importedNumber} members in the last 30 days.`,
emailVerificationEmailMessageAPI: `Email verification needed for site: {siteUrl} has added: {importedNumber} members through the API in the last 30 days.`
emailVerificationEmailMessageImport: `Email verification needed for site: {siteUrl}, has imported: {amountTriggered} members in the last 30 days.`,
emailVerificationEmailMessageAPI: `Email verification needed for site: {siteUrl} has added: {amountTriggered} members through the API in the last 30 days.`
};
class VerificationTrigger {
@ -16,7 +16,7 @@ class VerificationTrigger {
* @param {number} deps.apiTriggerThreshold Threshold for triggering verification as defined in config
* @param {() => boolean} deps.isVerified Check Ghost config to see if we are already verified
* @param {() => boolean} deps.isVerificationRequired Check Ghost settings to see whether verification has been requested
* @param {(content: {subject: string, message: string, amountImported: number}) => {}} deps.sendVerificationEmail Sends an email to the escalation address to confirm that customer needs to be verified
* @param {(content: {subject: string, message: string, amountTriggered: number}) => void} deps.sendVerificationEmail Sends an email to the escalation address to confirm that customer needs to be verified
* @param {any} deps.membersStats MemberStats service
* @param {any} deps.Settings Ghost Settings model
* @param {any} deps.eventRepository For querying events
@ -132,7 +132,7 @@ class VerificationTrigger {
? messages.emailVerificationEmailMessageAPI
: messages.emailVerificationEmailMessageImport,
subject: messages.emailVerificationEmailSubject,
amountImported
amountTriggered: amount
});
if (throwOnTrigger) {

View file

@ -151,7 +151,7 @@ describe('Email verification flow', function () {
emailStub.lastCall.firstArg.should.eql({
subject: 'Email needs verification',
message: 'Email verification needed for site: {siteUrl}, has imported: {importedNumber} members in the last 30 days.',
amountImported: 10
amountTriggered: 10
});
});
@ -167,7 +167,7 @@ describe('Email verification flow', function () {
});
new VerificationTrigger({
configThreshold: 2,
apiTriggerThreshold: 2,
Settings: {
edit: settingsStub
},
@ -230,9 +230,10 @@ describe('Email verification flow', function () {
emailStub.lastCall.firstArg.should.eql({
subject: 'Email needs verification',
message: 'Email verification needed for site: {siteUrl}, has imported: {importedNumber} members in the last 30 days.',
amountImported: 10
amountTriggered: 10
});
});
});
it('Does not fetch events and trigger when threshold is Infinity', async function () {
const emailStub = sinon.stub().resolves(null);