From bcfc3792cd8653f63caff5f7cf2d33a4e80ae578 Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Thu, 9 Jul 2020 17:55:40 +1200 Subject: [PATCH] Removed invalid and duplicate email validations in members importer --- .../app/services/member-import-validator.js | 33 ++----------------- .../services/member-import-validator-test.js | 5 ++- 2 files changed, 4 insertions(+), 34 deletions(-) diff --git a/ghost/admin/app/services/member-import-validator.js b/ghost/admin/app/services/member-import-validator.js index e1b1d780e0..14b90d9ec6 100644 --- a/ghost/admin/app/services/member-import-validator.js +++ b/ghost/admin/app/services/member-import-validator.js @@ -61,14 +61,7 @@ export default Service.extend({ })); } else { // check can be done on whole set as it won't be too slow - const {invalidCount, emptyCount, duplicateCount} = this._checkEmails(data, mapping); - if (invalidCount) { - // @TODO: Remove error from displayed errors - validationErrors.push(new MemberImportError({ - message: `Invalid email address (${formatNumber(invalidCount)})`, - type: 'warning' - })); - } + const {emptyCount} = this._checkEmails(data, mapping); if (emptyCount) { validationErrors.push(new MemberImportError({ @@ -76,14 +69,6 @@ export default Service.extend({ type: 'warning' })); } - - if (duplicateCount) { - // @TODO: Remove error from displayed errors - validationErrors.push(new MemberImportError({ - message: `Duplicate email address (${formatNumber(duplicateCount)})`, - type: 'warning' - })); - } } return {validationErrors, mapping}; @@ -184,29 +169,15 @@ export default Service.extend({ _checkEmails(validatedSet, mapping) { let emptyCount = 0; - let invalidCount = 0; - let duplicateCount = 0; - let emailMap = {}; validatedSet.forEach((member) => { let emailValue = member[mapping.email]; if (!emailValue) { emptyCount += 1; } - - if (emailValue && !validator.isEmail(emailValue)) { - invalidCount += 1; - } else if (emailValue) { - if (emailMap[emailValue]) { - emailMap[emailValue] += 1; - duplicateCount += 1; - } else { - emailMap[emailValue] = 1; - } - } }); - return {invalidCount, emptyCount, duplicateCount}; + return {emptyCount}; }, _countStripeRecors(validatedSet, mapping) { diff --git a/ghost/admin/tests/integration/services/member-import-validator-test.js b/ghost/admin/tests/integration/services/member-import-validator-test.js index cd0c9fa2fe..2cf821f3f1 100644 --- a/ghost/admin/tests/integration/services/member-import-validator-test.js +++ b/ghost/admin/tests/integration/services/member-import-validator-test.js @@ -77,7 +77,7 @@ describe('Integration: Service: member-import-validator', function () { expect(validationErrors[0].message).to.equal('No email addresses found in the uploaded CSV.'); }); - it('returns validation error for invalid email', async function () { + it('ignores validation for invalid email', async function () { this.owner.register('service:membersUtils', Service.extend({ isStripeEnabled: false })); @@ -90,8 +90,7 @@ describe('Integration: Service: member-import-validator', function () { email: 'email@example.com' }]); - expect(validationErrors.length).to.equal(1); - expect(validationErrors[0].message).to.equal('Invalid email address (1)'); + expect(validationErrors.length).to.equal(0); }); describe('data sampling method', function () {