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()
});
const processImport = async (options) => {
const result = await membersImporter.process(options);
const freezeTriggered = result.meta.freeze;
delete result.meta.freeze;
const startEmailVerification = async () => {
const isVerifiedEmail = config.get('hostSettings:emailVerification:verified') === true;
if ((!isVerifiedEmail) && freezeTriggered) {
if ((!isVerifiedEmail)) {
await models.Settings.edit([{
key: 'email_freeze',
value: true
@ -84,6 +80,16 @@ const processImport = async (options) => {
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;
};