mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 20:34:02 +03:00
Removed invalid and duplicate email validations in members importer
This commit is contained in:
parent
3086ac1439
commit
bcfc3792cd
@ -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) {
|
||||
|
@ -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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user