Moved email verification logic into separate method

refs https://github.com/TryGhost/Team/issues/912

- The processImport method was becoming to big and unreadable
- Having small methods is easier to extract if needed later
This commit is contained in:
Naz 2021-07-28 16:36:20 +04:00 committed by naz
parent 93e8814589
commit fa33235fd9

View File

@ -67,14 +67,10 @@ const membersImporter = new MembersCSVImporter({
importThreshold: getThreshold() importThreshold: getThreshold()
}); });
const processImport = async (options) => { const startEmailVerification = async () => {
const result = await membersImporter.process(options);
const freezeTriggered = result.meta.freeze;
delete result.meta.freeze;
const isVerifiedEmail = config.get('hostSettings:emailVerification:verified') === true; const isVerifiedEmail = config.get('hostSettings:emailVerification:verified') === true;
if ((!isVerifiedEmail) && freezeTriggered) { if ((!isVerifiedEmail)) {
await models.Settings.edit([{ await models.Settings.edit([{
key: 'email_freeze', key: 'email_freeze',
value: true value: true
@ -84,6 +80,16 @@ const processImport = async (options) => {
message: tpl(messages.emailVerificationNeeded) message: tpl(messages.emailVerificationNeeded)
}); });
} }
};
const processImport = async (options) => {
const result = await membersImporter.process(options);
const freezeTriggered = result.meta.freeze;
delete result.meta.freeze;
if (freezeTriggered) {
await startEmailVerification();
}
return result; return result;
}; };