mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Fixed verification trigger not working for large imports (#15887)
fixes https://github.com/TryGhost/Team/issues/2326 When importing more than 500 members, we didn't testImportThreshold at the right time. It was called too early because the importing job was not awaited. This also adds an E2E test for this case.
This commit is contained in:
parent
2a28fa411b
commit
6e72767a50
6 changed files with 592 additions and 25 deletions
|
@ -66,12 +66,7 @@ const membersImporter = new MembersCSVImporter({
|
||||||
});
|
});
|
||||||
|
|
||||||
const processImport = async (options) => {
|
const processImport = async (options) => {
|
||||||
const result = await membersImporter.process(options);
|
return await membersImporter.process({...options, verificationTrigger});
|
||||||
|
|
||||||
// Check whether all imports in last 30 days > threshold
|
|
||||||
await verificationTrigger.testImportThreshold();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateVerificationTrigger = () => {
|
const updateVerificationTrigger = () => {
|
||||||
|
|
|
@ -7,6 +7,7 @@ const localUtils = require('./utils');
|
||||||
const config = require('../../../../core/shared/config');
|
const config = require('../../../../core/shared/config');
|
||||||
const configUtils = require('../../../utils/configUtils');
|
const configUtils = require('../../../utils/configUtils');
|
||||||
const settingsCache = require('../../../../core/shared/settings-cache');
|
const settingsCache = require('../../../../core/shared/settings-cache');
|
||||||
|
const models = require('../../../../core/server/models');
|
||||||
|
|
||||||
const {mockManager} = require('../../../utils/e2e-framework');
|
const {mockManager} = require('../../../utils/e2e-framework');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
@ -14,6 +15,12 @@ const {_updateVerificationTrigger} = require('../../../../core/server/services/m
|
||||||
|
|
||||||
let request;
|
let request;
|
||||||
|
|
||||||
|
async function sleep(ms) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, ms);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
describe('Members Importer API', function () {
|
describe('Members Importer API', function () {
|
||||||
before(async function () {
|
before(async function () {
|
||||||
await localUtils.startGhost();
|
await localUtils.startGhost();
|
||||||
|
@ -302,4 +309,46 @@ describe('Members Importer API', function () {
|
||||||
// Don't send another email
|
// Don't send another email
|
||||||
mockManager.assert.sentEmailCount(0);
|
mockManager.assert.sentEmailCount(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Can import members with host emailVerification limits for large imports', async function () {
|
||||||
|
await models.Settings.edit([{
|
||||||
|
key: 'email_verification_required',
|
||||||
|
value: false
|
||||||
|
}], {context: {internal: true}});
|
||||||
|
|
||||||
|
assert(!settingsCache.get('email_verification_required'), 'Email verification should not be required');
|
||||||
|
|
||||||
|
// If this test fails, check if the total members that have been created with fixtures has increased a lot, and if required, increase the amount of imported members
|
||||||
|
configUtils.set('hostSettings:emailVerification', {
|
||||||
|
apiThreshold: 2,
|
||||||
|
adminThreshold: 2,
|
||||||
|
importThreshold: 1, // note: this one isn't really used because (totalMembers - members_created_in_last_30_days) is larger and used instead
|
||||||
|
verified: false,
|
||||||
|
escalationAddress: 'test@example.com'
|
||||||
|
});
|
||||||
|
_updateVerificationTrigger();
|
||||||
|
|
||||||
|
const res = await request
|
||||||
|
.post(localUtils.API.getApiQuery(`members/upload/`))
|
||||||
|
.field('labels', ['new-global-label'])
|
||||||
|
.attach('membersfile', path.join(__dirname, '/../../../utils/fixtures/csv/valid-members-import-large-501.csv'))
|
||||||
|
.set('Origin', config.get('url'))
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
|
.expect(202);
|
||||||
|
should.not.exist(res.headers['x-cache-invalidate']);
|
||||||
|
const jsonResponse = res.body;
|
||||||
|
|
||||||
|
should.exist(jsonResponse);
|
||||||
|
should.exist(jsonResponse.meta);
|
||||||
|
|
||||||
|
// Wait for the job to finish
|
||||||
|
await sleep(2500);
|
||||||
|
|
||||||
|
assert(!!settingsCache.get('email_verification_required'), 'Email verification should now be required');
|
||||||
|
|
||||||
|
mockManager.assert.sentEmail({
|
||||||
|
subject: 'Email needs verification'
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,502 @@
|
||||||
|
email,name,note,subscribed_to_emails,labels
|
||||||
|
test1@example.com,test,"test note",false,"test-label"
|
||||||
|
test2@example.com,test,"test note",false,"test-label"
|
||||||
|
test3@example.com,test,"test note",false,"test-label"
|
||||||
|
test4@example.com,test,"test note",false,"test-label"
|
||||||
|
test5@example.com,test,"test note",false,"test-label"
|
||||||
|
test6@example.com,test,"test note",false,"test-label"
|
||||||
|
test7@example.com,test,"test note",false,"test-label"
|
||||||
|
test8@example.com,test,"test note",false,"test-label"
|
||||||
|
test9@example.com,test,"test note",false,"test-label"
|
||||||
|
test10@example.com,test,"test note",false,"test-label"
|
||||||
|
test11@example.com,test,"test note",false,"test-label"
|
||||||
|
test12@example.com,test,"test note",false,"test-label"
|
||||||
|
test13@example.com,test,"test note",false,"test-label"
|
||||||
|
test14@example.com,test,"test note",false,"test-label"
|
||||||
|
test15@example.com,test,"test note",false,"test-label"
|
||||||
|
test16@example.com,test,"test note",false,"test-label"
|
||||||
|
test17@example.com,test,"test note",false,"test-label"
|
||||||
|
test18@example.com,test,"test note",false,"test-label"
|
||||||
|
test19@example.com,test,"test note",false,"test-label"
|
||||||
|
test20@example.com,test,"test note",false,"test-label"
|
||||||
|
test21@example.com,test,"test note",false,"test-label"
|
||||||
|
test22@example.com,test,"test note",false,"test-label"
|
||||||
|
test23@example.com,test,"test note",false,"test-label"
|
||||||
|
test24@example.com,test,"test note",false,"test-label"
|
||||||
|
test25@example.com,test,"test note",false,"test-label"
|
||||||
|
test26@example.com,test,"test note",false,"test-label"
|
||||||
|
test27@example.com,test,"test note",false,"test-label"
|
||||||
|
test28@example.com,test,"test note",false,"test-label"
|
||||||
|
test29@example.com,test,"test note",false,"test-label"
|
||||||
|
test30@example.com,test,"test note",false,"test-label"
|
||||||
|
test31@example.com,test,"test note",false,"test-label"
|
||||||
|
test32@example.com,test,"test note",false,"test-label"
|
||||||
|
test33@example.com,test,"test note",false,"test-label"
|
||||||
|
test34@example.com,test,"test note",false,"test-label"
|
||||||
|
test35@example.com,test,"test note",false,"test-label"
|
||||||
|
test36@example.com,test,"test note",false,"test-label"
|
||||||
|
test37@example.com,test,"test note",false,"test-label"
|
||||||
|
test38@example.com,test,"test note",false,"test-label"
|
||||||
|
test39@example.com,test,"test note",false,"test-label"
|
||||||
|
test40@example.com,test,"test note",false,"test-label"
|
||||||
|
test41@example.com,test,"test note",false,"test-label"
|
||||||
|
test42@example.com,test,"test note",false,"test-label"
|
||||||
|
test43@example.com,test,"test note",false,"test-label"
|
||||||
|
test44@example.com,test,"test note",false,"test-label"
|
||||||
|
test45@example.com,test,"test note",false,"test-label"
|
||||||
|
test46@example.com,test,"test note",false,"test-label"
|
||||||
|
test47@example.com,test,"test note",false,"test-label"
|
||||||
|
test48@example.com,test,"test note",false,"test-label"
|
||||||
|
test49@example.com,test,"test note",false,"test-label"
|
||||||
|
test50@example.com,test,"test note",false,"test-label"
|
||||||
|
test51@example.com,test,"test note",false,"test-label"
|
||||||
|
test52@example.com,test,"test note",false,"test-label"
|
||||||
|
test53@example.com,test,"test note",false,"test-label"
|
||||||
|
test54@example.com,test,"test note",false,"test-label"
|
||||||
|
test55@example.com,test,"test note",false,"test-label"
|
||||||
|
test56@example.com,test,"test note",false,"test-label"
|
||||||
|
test57@example.com,test,"test note",false,"test-label"
|
||||||
|
test58@example.com,test,"test note",false,"test-label"
|
||||||
|
test59@example.com,test,"test note",false,"test-label"
|
||||||
|
test60@example.com,test,"test note",false,"test-label"
|
||||||
|
test61@example.com,test,"test note",false,"test-label"
|
||||||
|
test62@example.com,test,"test note",false,"test-label"
|
||||||
|
test63@example.com,test,"test note",false,"test-label"
|
||||||
|
test64@example.com,test,"test note",false,"test-label"
|
||||||
|
test65@example.com,test,"test note",false,"test-label"
|
||||||
|
test66@example.com,test,"test note",false,"test-label"
|
||||||
|
test67@example.com,test,"test note",false,"test-label"
|
||||||
|
test68@example.com,test,"test note",false,"test-label"
|
||||||
|
test69@example.com,test,"test note",false,"test-label"
|
||||||
|
test70@example.com,test,"test note",false,"test-label"
|
||||||
|
test71@example.com,test,"test note",false,"test-label"
|
||||||
|
test72@example.com,test,"test note",false,"test-label"
|
||||||
|
test73@example.com,test,"test note",false,"test-label"
|
||||||
|
test74@example.com,test,"test note",false,"test-label"
|
||||||
|
test75@example.com,test,"test note",false,"test-label"
|
||||||
|
test76@example.com,test,"test note",false,"test-label"
|
||||||
|
test77@example.com,test,"test note",false,"test-label"
|
||||||
|
test78@example.com,test,"test note",false,"test-label"
|
||||||
|
test79@example.com,test,"test note",false,"test-label"
|
||||||
|
test80@example.com,test,"test note",false,"test-label"
|
||||||
|
test81@example.com,test,"test note",false,"test-label"
|
||||||
|
test82@example.com,test,"test note",false,"test-label"
|
||||||
|
test83@example.com,test,"test note",false,"test-label"
|
||||||
|
test84@example.com,test,"test note",false,"test-label"
|
||||||
|
test85@example.com,test,"test note",false,"test-label"
|
||||||
|
test86@example.com,test,"test note",false,"test-label"
|
||||||
|
test87@example.com,test,"test note",false,"test-label"
|
||||||
|
test88@example.com,test,"test note",false,"test-label"
|
||||||
|
test89@example.com,test,"test note",false,"test-label"
|
||||||
|
test90@example.com,test,"test note",false,"test-label"
|
||||||
|
test91@example.com,test,"test note",false,"test-label"
|
||||||
|
test92@example.com,test,"test note",false,"test-label"
|
||||||
|
test93@example.com,test,"test note",false,"test-label"
|
||||||
|
test94@example.com,test,"test note",false,"test-label"
|
||||||
|
test95@example.com,test,"test note",false,"test-label"
|
||||||
|
test96@example.com,test,"test note",false,"test-label"
|
||||||
|
test97@example.com,test,"test note",false,"test-label"
|
||||||
|
test98@example.com,test,"test note",false,"test-label"
|
||||||
|
test99@example.com,test,"test note",false,"test-label"
|
||||||
|
test100@example.com,test,"test note",false,"test-label"
|
||||||
|
test101@example.com,test,"test note",false,"test-label"
|
||||||
|
test102@example.com,test,"test note",false,"test-label"
|
||||||
|
test103@example.com,test,"test note",false,"test-label"
|
||||||
|
test104@example.com,test,"test note",false,"test-label"
|
||||||
|
test105@example.com,test,"test note",false,"test-label"
|
||||||
|
test106@example.com,test,"test note",false,"test-label"
|
||||||
|
test107@example.com,test,"test note",false,"test-label"
|
||||||
|
test108@example.com,test,"test note",false,"test-label"
|
||||||
|
test109@example.com,test,"test note",false,"test-label"
|
||||||
|
test110@example.com,test,"test note",false,"test-label"
|
||||||
|
test111@example.com,test,"test note",false,"test-label"
|
||||||
|
test112@example.com,test,"test note",false,"test-label"
|
||||||
|
test113@example.com,test,"test note",false,"test-label"
|
||||||
|
test114@example.com,test,"test note",false,"test-label"
|
||||||
|
test115@example.com,test,"test note",false,"test-label"
|
||||||
|
test116@example.com,test,"test note",false,"test-label"
|
||||||
|
test117@example.com,test,"test note",false,"test-label"
|
||||||
|
test118@example.com,test,"test note",false,"test-label"
|
||||||
|
test119@example.com,test,"test note",false,"test-label"
|
||||||
|
test120@example.com,test,"test note",false,"test-label"
|
||||||
|
test121@example.com,test,"test note",false,"test-label"
|
||||||
|
test122@example.com,test,"test note",false,"test-label"
|
||||||
|
test123@example.com,test,"test note",false,"test-label"
|
||||||
|
test124@example.com,test,"test note",false,"test-label"
|
||||||
|
test125@example.com,test,"test note",false,"test-label"
|
||||||
|
test126@example.com,test,"test note",false,"test-label"
|
||||||
|
test127@example.com,test,"test note",false,"test-label"
|
||||||
|
test128@example.com,test,"test note",false,"test-label"
|
||||||
|
test129@example.com,test,"test note",false,"test-label"
|
||||||
|
test130@example.com,test,"test note",false,"test-label"
|
||||||
|
test131@example.com,test,"test note",false,"test-label"
|
||||||
|
test132@example.com,test,"test note",false,"test-label"
|
||||||
|
test133@example.com,test,"test note",false,"test-label"
|
||||||
|
test134@example.com,test,"test note",false,"test-label"
|
||||||
|
test135@example.com,test,"test note",false,"test-label"
|
||||||
|
test136@example.com,test,"test note",false,"test-label"
|
||||||
|
test137@example.com,test,"test note",false,"test-label"
|
||||||
|
test138@example.com,test,"test note",false,"test-label"
|
||||||
|
test139@example.com,test,"test note",false,"test-label"
|
||||||
|
test140@example.com,test,"test note",false,"test-label"
|
||||||
|
test141@example.com,test,"test note",false,"test-label"
|
||||||
|
test142@example.com,test,"test note",false,"test-label"
|
||||||
|
test143@example.com,test,"test note",false,"test-label"
|
||||||
|
test144@example.com,test,"test note",false,"test-label"
|
||||||
|
test145@example.com,test,"test note",false,"test-label"
|
||||||
|
test146@example.com,test,"test note",false,"test-label"
|
||||||
|
test147@example.com,test,"test note",false,"test-label"
|
||||||
|
test148@example.com,test,"test note",false,"test-label"
|
||||||
|
test149@example.com,test,"test note",false,"test-label"
|
||||||
|
test150@example.com,test,"test note",false,"test-label"
|
||||||
|
test151@example.com,test,"test note",false,"test-label"
|
||||||
|
test152@example.com,test,"test note",false,"test-label"
|
||||||
|
test153@example.com,test,"test note",false,"test-label"
|
||||||
|
test154@example.com,test,"test note",false,"test-label"
|
||||||
|
test155@example.com,test,"test note",false,"test-label"
|
||||||
|
test156@example.com,test,"test note",false,"test-label"
|
||||||
|
test157@example.com,test,"test note",false,"test-label"
|
||||||
|
test158@example.com,test,"test note",false,"test-label"
|
||||||
|
test159@example.com,test,"test note",false,"test-label"
|
||||||
|
test160@example.com,test,"test note",false,"test-label"
|
||||||
|
test161@example.com,test,"test note",false,"test-label"
|
||||||
|
test162@example.com,test,"test note",false,"test-label"
|
||||||
|
test163@example.com,test,"test note",false,"test-label"
|
||||||
|
test164@example.com,test,"test note",false,"test-label"
|
||||||
|
test165@example.com,test,"test note",false,"test-label"
|
||||||
|
test166@example.com,test,"test note",false,"test-label"
|
||||||
|
test167@example.com,test,"test note",false,"test-label"
|
||||||
|
test168@example.com,test,"test note",false,"test-label"
|
||||||
|
test169@example.com,test,"test note",false,"test-label"
|
||||||
|
test170@example.com,test,"test note",false,"test-label"
|
||||||
|
test171@example.com,test,"test note",false,"test-label"
|
||||||
|
test172@example.com,test,"test note",false,"test-label"
|
||||||
|
test173@example.com,test,"test note",false,"test-label"
|
||||||
|
test174@example.com,test,"test note",false,"test-label"
|
||||||
|
test175@example.com,test,"test note",false,"test-label"
|
||||||
|
test176@example.com,test,"test note",false,"test-label"
|
||||||
|
test177@example.com,test,"test note",false,"test-label"
|
||||||
|
test178@example.com,test,"test note",false,"test-label"
|
||||||
|
test179@example.com,test,"test note",false,"test-label"
|
||||||
|
test180@example.com,test,"test note",false,"test-label"
|
||||||
|
test181@example.com,test,"test note",false,"test-label"
|
||||||
|
test182@example.com,test,"test note",false,"test-label"
|
||||||
|
test183@example.com,test,"test note",false,"test-label"
|
||||||
|
test184@example.com,test,"test note",false,"test-label"
|
||||||
|
test185@example.com,test,"test note",false,"test-label"
|
||||||
|
test186@example.com,test,"test note",false,"test-label"
|
||||||
|
test187@example.com,test,"test note",false,"test-label"
|
||||||
|
test188@example.com,test,"test note",false,"test-label"
|
||||||
|
test189@example.com,test,"test note",false,"test-label"
|
||||||
|
test190@example.com,test,"test note",false,"test-label"
|
||||||
|
test191@example.com,test,"test note",false,"test-label"
|
||||||
|
test192@example.com,test,"test note",false,"test-label"
|
||||||
|
test193@example.com,test,"test note",false,"test-label"
|
||||||
|
test194@example.com,test,"test note",false,"test-label"
|
||||||
|
test195@example.com,test,"test note",false,"test-label"
|
||||||
|
test196@example.com,test,"test note",false,"test-label"
|
||||||
|
test197@example.com,test,"test note",false,"test-label"
|
||||||
|
test198@example.com,test,"test note",false,"test-label"
|
||||||
|
test199@example.com,test,"test note",false,"test-label"
|
||||||
|
test200@example.com,test,"test note",false,"test-label"
|
||||||
|
test201@example.com,test,"test note",false,"test-label"
|
||||||
|
test202@example.com,test,"test note",false,"test-label"
|
||||||
|
test203@example.com,test,"test note",false,"test-label"
|
||||||
|
test204@example.com,test,"test note",false,"test-label"
|
||||||
|
test205@example.com,test,"test note",false,"test-label"
|
||||||
|
test206@example.com,test,"test note",false,"test-label"
|
||||||
|
test207@example.com,test,"test note",false,"test-label"
|
||||||
|
test208@example.com,test,"test note",false,"test-label"
|
||||||
|
test209@example.com,test,"test note",false,"test-label"
|
||||||
|
test210@example.com,test,"test note",false,"test-label"
|
||||||
|
test211@example.com,test,"test note",false,"test-label"
|
||||||
|
test212@example.com,test,"test note",false,"test-label"
|
||||||
|
test213@example.com,test,"test note",false,"test-label"
|
||||||
|
test214@example.com,test,"test note",false,"test-label"
|
||||||
|
test215@example.com,test,"test note",false,"test-label"
|
||||||
|
test216@example.com,test,"test note",false,"test-label"
|
||||||
|
test217@example.com,test,"test note",false,"test-label"
|
||||||
|
test218@example.com,test,"test note",false,"test-label"
|
||||||
|
test219@example.com,test,"test note",false,"test-label"
|
||||||
|
test220@example.com,test,"test note",false,"test-label"
|
||||||
|
test221@example.com,test,"test note",false,"test-label"
|
||||||
|
test222@example.com,test,"test note",false,"test-label"
|
||||||
|
test223@example.com,test,"test note",false,"test-label"
|
||||||
|
test224@example.com,test,"test note",false,"test-label"
|
||||||
|
test225@example.com,test,"test note",false,"test-label"
|
||||||
|
test226@example.com,test,"test note",false,"test-label"
|
||||||
|
test227@example.com,test,"test note",false,"test-label"
|
||||||
|
test228@example.com,test,"test note",false,"test-label"
|
||||||
|
test229@example.com,test,"test note",false,"test-label"
|
||||||
|
test230@example.com,test,"test note",false,"test-label"
|
||||||
|
test231@example.com,test,"test note",false,"test-label"
|
||||||
|
test232@example.com,test,"test note",false,"test-label"
|
||||||
|
test233@example.com,test,"test note",false,"test-label"
|
||||||
|
test234@example.com,test,"test note",false,"test-label"
|
||||||
|
test235@example.com,test,"test note",false,"test-label"
|
||||||
|
test236@example.com,test,"test note",false,"test-label"
|
||||||
|
test237@example.com,test,"test note",false,"test-label"
|
||||||
|
test238@example.com,test,"test note",false,"test-label"
|
||||||
|
test239@example.com,test,"test note",false,"test-label"
|
||||||
|
test240@example.com,test,"test note",false,"test-label"
|
||||||
|
test241@example.com,test,"test note",false,"test-label"
|
||||||
|
test242@example.com,test,"test note",false,"test-label"
|
||||||
|
test243@example.com,test,"test note",false,"test-label"
|
||||||
|
test244@example.com,test,"test note",false,"test-label"
|
||||||
|
test245@example.com,test,"test note",false,"test-label"
|
||||||
|
test246@example.com,test,"test note",false,"test-label"
|
||||||
|
test247@example.com,test,"test note",false,"test-label"
|
||||||
|
test248@example.com,test,"test note",false,"test-label"
|
||||||
|
test249@example.com,test,"test note",false,"test-label"
|
||||||
|
test250@example.com,test,"test note",false,"test-label"
|
||||||
|
test251@example.com,test,"test note",false,"test-label"
|
||||||
|
test252@example.com,test,"test note",false,"test-label"
|
||||||
|
test253@example.com,test,"test note",false,"test-label"
|
||||||
|
test254@example.com,test,"test note",false,"test-label"
|
||||||
|
test255@example.com,test,"test note",false,"test-label"
|
||||||
|
test256@example.com,test,"test note",false,"test-label"
|
||||||
|
test257@example.com,test,"test note",false,"test-label"
|
||||||
|
test258@example.com,test,"test note",false,"test-label"
|
||||||
|
test259@example.com,test,"test note",false,"test-label"
|
||||||
|
test260@example.com,test,"test note",false,"test-label"
|
||||||
|
test261@example.com,test,"test note",false,"test-label"
|
||||||
|
test262@example.com,test,"test note",false,"test-label"
|
||||||
|
test263@example.com,test,"test note",false,"test-label"
|
||||||
|
test264@example.com,test,"test note",false,"test-label"
|
||||||
|
test265@example.com,test,"test note",false,"test-label"
|
||||||
|
test266@example.com,test,"test note",false,"test-label"
|
||||||
|
test267@example.com,test,"test note",false,"test-label"
|
||||||
|
test268@example.com,test,"test note",false,"test-label"
|
||||||
|
test269@example.com,test,"test note",false,"test-label"
|
||||||
|
test270@example.com,test,"test note",false,"test-label"
|
||||||
|
test271@example.com,test,"test note",false,"test-label"
|
||||||
|
test272@example.com,test,"test note",false,"test-label"
|
||||||
|
test273@example.com,test,"test note",false,"test-label"
|
||||||
|
test274@example.com,test,"test note",false,"test-label"
|
||||||
|
test275@example.com,test,"test note",false,"test-label"
|
||||||
|
test276@example.com,test,"test note",false,"test-label"
|
||||||
|
test277@example.com,test,"test note",false,"test-label"
|
||||||
|
test278@example.com,test,"test note",false,"test-label"
|
||||||
|
test279@example.com,test,"test note",false,"test-label"
|
||||||
|
test280@example.com,test,"test note",false,"test-label"
|
||||||
|
test281@example.com,test,"test note",false,"test-label"
|
||||||
|
test282@example.com,test,"test note",false,"test-label"
|
||||||
|
test283@example.com,test,"test note",false,"test-label"
|
||||||
|
test284@example.com,test,"test note",false,"test-label"
|
||||||
|
test285@example.com,test,"test note",false,"test-label"
|
||||||
|
test286@example.com,test,"test note",false,"test-label"
|
||||||
|
test287@example.com,test,"test note",false,"test-label"
|
||||||
|
test288@example.com,test,"test note",false,"test-label"
|
||||||
|
test289@example.com,test,"test note",false,"test-label"
|
||||||
|
test290@example.com,test,"test note",false,"test-label"
|
||||||
|
test291@example.com,test,"test note",false,"test-label"
|
||||||
|
test292@example.com,test,"test note",false,"test-label"
|
||||||
|
test293@example.com,test,"test note",false,"test-label"
|
||||||
|
test294@example.com,test,"test note",false,"test-label"
|
||||||
|
test295@example.com,test,"test note",false,"test-label"
|
||||||
|
test296@example.com,test,"test note",false,"test-label"
|
||||||
|
test297@example.com,test,"test note",false,"test-label"
|
||||||
|
test298@example.com,test,"test note",false,"test-label"
|
||||||
|
test299@example.com,test,"test note",false,"test-label"
|
||||||
|
test300@example.com,test,"test note",false,"test-label"
|
||||||
|
test301@example.com,test,"test note",false,"test-label"
|
||||||
|
test302@example.com,test,"test note",false,"test-label"
|
||||||
|
test303@example.com,test,"test note",false,"test-label"
|
||||||
|
test304@example.com,test,"test note",false,"test-label"
|
||||||
|
test305@example.com,test,"test note",false,"test-label"
|
||||||
|
test306@example.com,test,"test note",false,"test-label"
|
||||||
|
test307@example.com,test,"test note",false,"test-label"
|
||||||
|
test308@example.com,test,"test note",false,"test-label"
|
||||||
|
test309@example.com,test,"test note",false,"test-label"
|
||||||
|
test310@example.com,test,"test note",false,"test-label"
|
||||||
|
test311@example.com,test,"test note",false,"test-label"
|
||||||
|
test312@example.com,test,"test note",false,"test-label"
|
||||||
|
test313@example.com,test,"test note",false,"test-label"
|
||||||
|
test314@example.com,test,"test note",false,"test-label"
|
||||||
|
test315@example.com,test,"test note",false,"test-label"
|
||||||
|
test316@example.com,test,"test note",false,"test-label"
|
||||||
|
test317@example.com,test,"test note",false,"test-label"
|
||||||
|
test318@example.com,test,"test note",false,"test-label"
|
||||||
|
test319@example.com,test,"test note",false,"test-label"
|
||||||
|
test320@example.com,test,"test note",false,"test-label"
|
||||||
|
test321@example.com,test,"test note",false,"test-label"
|
||||||
|
test322@example.com,test,"test note",false,"test-label"
|
||||||
|
test323@example.com,test,"test note",false,"test-label"
|
||||||
|
test324@example.com,test,"test note",false,"test-label"
|
||||||
|
test325@example.com,test,"test note",false,"test-label"
|
||||||
|
test326@example.com,test,"test note",false,"test-label"
|
||||||
|
test327@example.com,test,"test note",false,"test-label"
|
||||||
|
test328@example.com,test,"test note",false,"test-label"
|
||||||
|
test329@example.com,test,"test note",false,"test-label"
|
||||||
|
test330@example.com,test,"test note",false,"test-label"
|
||||||
|
test331@example.com,test,"test note",false,"test-label"
|
||||||
|
test332@example.com,test,"test note",false,"test-label"
|
||||||
|
test333@example.com,test,"test note",false,"test-label"
|
||||||
|
test334@example.com,test,"test note",false,"test-label"
|
||||||
|
test335@example.com,test,"test note",false,"test-label"
|
||||||
|
test336@example.com,test,"test note",false,"test-label"
|
||||||
|
test337@example.com,test,"test note",false,"test-label"
|
||||||
|
test338@example.com,test,"test note",false,"test-label"
|
||||||
|
test339@example.com,test,"test note",false,"test-label"
|
||||||
|
test340@example.com,test,"test note",false,"test-label"
|
||||||
|
test341@example.com,test,"test note",false,"test-label"
|
||||||
|
test342@example.com,test,"test note",false,"test-label"
|
||||||
|
test343@example.com,test,"test note",false,"test-label"
|
||||||
|
test344@example.com,test,"test note",false,"test-label"
|
||||||
|
test345@example.com,test,"test note",false,"test-label"
|
||||||
|
test346@example.com,test,"test note",false,"test-label"
|
||||||
|
test347@example.com,test,"test note",false,"test-label"
|
||||||
|
test348@example.com,test,"test note",false,"test-label"
|
||||||
|
test349@example.com,test,"test note",false,"test-label"
|
||||||
|
test350@example.com,test,"test note",false,"test-label"
|
||||||
|
test351@example.com,test,"test note",false,"test-label"
|
||||||
|
test352@example.com,test,"test note",false,"test-label"
|
||||||
|
test353@example.com,test,"test note",false,"test-label"
|
||||||
|
test354@example.com,test,"test note",false,"test-label"
|
||||||
|
test355@example.com,test,"test note",false,"test-label"
|
||||||
|
test356@example.com,test,"test note",false,"test-label"
|
||||||
|
test357@example.com,test,"test note",false,"test-label"
|
||||||
|
test358@example.com,test,"test note",false,"test-label"
|
||||||
|
test359@example.com,test,"test note",false,"test-label"
|
||||||
|
test360@example.com,test,"test note",false,"test-label"
|
||||||
|
test361@example.com,test,"test note",false,"test-label"
|
||||||
|
test362@example.com,test,"test note",false,"test-label"
|
||||||
|
test363@example.com,test,"test note",false,"test-label"
|
||||||
|
test364@example.com,test,"test note",false,"test-label"
|
||||||
|
test365@example.com,test,"test note",false,"test-label"
|
||||||
|
test366@example.com,test,"test note",false,"test-label"
|
||||||
|
test367@example.com,test,"test note",false,"test-label"
|
||||||
|
test368@example.com,test,"test note",false,"test-label"
|
||||||
|
test369@example.com,test,"test note",false,"test-label"
|
||||||
|
test370@example.com,test,"test note",false,"test-label"
|
||||||
|
test371@example.com,test,"test note",false,"test-label"
|
||||||
|
test372@example.com,test,"test note",false,"test-label"
|
||||||
|
test373@example.com,test,"test note",false,"test-label"
|
||||||
|
test374@example.com,test,"test note",false,"test-label"
|
||||||
|
test375@example.com,test,"test note",false,"test-label"
|
||||||
|
test376@example.com,test,"test note",false,"test-label"
|
||||||
|
test377@example.com,test,"test note",false,"test-label"
|
||||||
|
test378@example.com,test,"test note",false,"test-label"
|
||||||
|
test379@example.com,test,"test note",false,"test-label"
|
||||||
|
test380@example.com,test,"test note",false,"test-label"
|
||||||
|
test381@example.com,test,"test note",false,"test-label"
|
||||||
|
test382@example.com,test,"test note",false,"test-label"
|
||||||
|
test383@example.com,test,"test note",false,"test-label"
|
||||||
|
test384@example.com,test,"test note",false,"test-label"
|
||||||
|
test385@example.com,test,"test note",false,"test-label"
|
||||||
|
test386@example.com,test,"test note",false,"test-label"
|
||||||
|
test387@example.com,test,"test note",false,"test-label"
|
||||||
|
test388@example.com,test,"test note",false,"test-label"
|
||||||
|
test389@example.com,test,"test note",false,"test-label"
|
||||||
|
test390@example.com,test,"test note",false,"test-label"
|
||||||
|
test391@example.com,test,"test note",false,"test-label"
|
||||||
|
test392@example.com,test,"test note",false,"test-label"
|
||||||
|
test393@example.com,test,"test note",false,"test-label"
|
||||||
|
test394@example.com,test,"test note",false,"test-label"
|
||||||
|
test395@example.com,test,"test note",false,"test-label"
|
||||||
|
test396@example.com,test,"test note",false,"test-label"
|
||||||
|
test397@example.com,test,"test note",false,"test-label"
|
||||||
|
test398@example.com,test,"test note",false,"test-label"
|
||||||
|
test399@example.com,test,"test note",false,"test-label"
|
||||||
|
test400@example.com,test,"test note",false,"test-label"
|
||||||
|
test401@example.com,test,"test note",false,"test-label"
|
||||||
|
test402@example.com,test,"test note",false,"test-label"
|
||||||
|
test403@example.com,test,"test note",false,"test-label"
|
||||||
|
test404@example.com,test,"test note",false,"test-label"
|
||||||
|
test405@example.com,test,"test note",false,"test-label"
|
||||||
|
test406@example.com,test,"test note",false,"test-label"
|
||||||
|
test407@example.com,test,"test note",false,"test-label"
|
||||||
|
test408@example.com,test,"test note",false,"test-label"
|
||||||
|
test409@example.com,test,"test note",false,"test-label"
|
||||||
|
test410@example.com,test,"test note",false,"test-label"
|
||||||
|
test411@example.com,test,"test note",false,"test-label"
|
||||||
|
test412@example.com,test,"test note",false,"test-label"
|
||||||
|
test413@example.com,test,"test note",false,"test-label"
|
||||||
|
test414@example.com,test,"test note",false,"test-label"
|
||||||
|
test415@example.com,test,"test note",false,"test-label"
|
||||||
|
test416@example.com,test,"test note",false,"test-label"
|
||||||
|
test417@example.com,test,"test note",false,"test-label"
|
||||||
|
test418@example.com,test,"test note",false,"test-label"
|
||||||
|
test419@example.com,test,"test note",false,"test-label"
|
||||||
|
test420@example.com,test,"test note",false,"test-label"
|
||||||
|
test421@example.com,test,"test note",false,"test-label"
|
||||||
|
test422@example.com,test,"test note",false,"test-label"
|
||||||
|
test423@example.com,test,"test note",false,"test-label"
|
||||||
|
test424@example.com,test,"test note",false,"test-label"
|
||||||
|
test425@example.com,test,"test note",false,"test-label"
|
||||||
|
test426@example.com,test,"test note",false,"test-label"
|
||||||
|
test427@example.com,test,"test note",false,"test-label"
|
||||||
|
test428@example.com,test,"test note",false,"test-label"
|
||||||
|
test429@example.com,test,"test note",false,"test-label"
|
||||||
|
test430@example.com,test,"test note",false,"test-label"
|
||||||
|
test431@example.com,test,"test note",false,"test-label"
|
||||||
|
test432@example.com,test,"test note",false,"test-label"
|
||||||
|
test433@example.com,test,"test note",false,"test-label"
|
||||||
|
test434@example.com,test,"test note",false,"test-label"
|
||||||
|
test435@example.com,test,"test note",false,"test-label"
|
||||||
|
test436@example.com,test,"test note",false,"test-label"
|
||||||
|
test437@example.com,test,"test note",false,"test-label"
|
||||||
|
test438@example.com,test,"test note",false,"test-label"
|
||||||
|
test439@example.com,test,"test note",false,"test-label"
|
||||||
|
test440@example.com,test,"test note",false,"test-label"
|
||||||
|
test441@example.com,test,"test note",false,"test-label"
|
||||||
|
test442@example.com,test,"test note",false,"test-label"
|
||||||
|
test443@example.com,test,"test note",false,"test-label"
|
||||||
|
test444@example.com,test,"test note",false,"test-label"
|
||||||
|
test445@example.com,test,"test note",false,"test-label"
|
||||||
|
test446@example.com,test,"test note",false,"test-label"
|
||||||
|
test447@example.com,test,"test note",false,"test-label"
|
||||||
|
test448@example.com,test,"test note",false,"test-label"
|
||||||
|
test449@example.com,test,"test note",false,"test-label"
|
||||||
|
test450@example.com,test,"test note",false,"test-label"
|
||||||
|
test451@example.com,test,"test note",false,"test-label"
|
||||||
|
test452@example.com,test,"test note",false,"test-label"
|
||||||
|
test453@example.com,test,"test note",false,"test-label"
|
||||||
|
test454@example.com,test,"test note",false,"test-label"
|
||||||
|
test455@example.com,test,"test note",false,"test-label"
|
||||||
|
test456@example.com,test,"test note",false,"test-label"
|
||||||
|
test457@example.com,test,"test note",false,"test-label"
|
||||||
|
test458@example.com,test,"test note",false,"test-label"
|
||||||
|
test459@example.com,test,"test note",false,"test-label"
|
||||||
|
test460@example.com,test,"test note",false,"test-label"
|
||||||
|
test461@example.com,test,"test note",false,"test-label"
|
||||||
|
test462@example.com,test,"test note",false,"test-label"
|
||||||
|
test463@example.com,test,"test note",false,"test-label"
|
||||||
|
test464@example.com,test,"test note",false,"test-label"
|
||||||
|
test465@example.com,test,"test note",false,"test-label"
|
||||||
|
test466@example.com,test,"test note",false,"test-label"
|
||||||
|
test467@example.com,test,"test note",false,"test-label"
|
||||||
|
test468@example.com,test,"test note",false,"test-label"
|
||||||
|
test469@example.com,test,"test note",false,"test-label"
|
||||||
|
test470@example.com,test,"test note",false,"test-label"
|
||||||
|
test471@example.com,test,"test note",false,"test-label"
|
||||||
|
test472@example.com,test,"test note",false,"test-label"
|
||||||
|
test473@example.com,test,"test note",false,"test-label"
|
||||||
|
test474@example.com,test,"test note",false,"test-label"
|
||||||
|
test475@example.com,test,"test note",false,"test-label"
|
||||||
|
test476@example.com,test,"test note",false,"test-label"
|
||||||
|
test477@example.com,test,"test note",false,"test-label"
|
||||||
|
test478@example.com,test,"test note",false,"test-label"
|
||||||
|
test479@example.com,test,"test note",false,"test-label"
|
||||||
|
test480@example.com,test,"test note",false,"test-label"
|
||||||
|
test481@example.com,test,"test note",false,"test-label"
|
||||||
|
test482@example.com,test,"test note",false,"test-label"
|
||||||
|
test483@example.com,test,"test note",false,"test-label"
|
||||||
|
test484@example.com,test,"test note",false,"test-label"
|
||||||
|
test485@example.com,test,"test note",false,"test-label"
|
||||||
|
test486@example.com,test,"test note",false,"test-label"
|
||||||
|
test487@example.com,test,"test note",false,"test-label"
|
||||||
|
test488@example.com,test,"test note",false,"test-label"
|
||||||
|
test489@example.com,test,"test note",false,"test-label"
|
||||||
|
test490@example.com,test,"test note",false,"test-label"
|
||||||
|
test491@example.com,test,"test note",false,"test-label"
|
||||||
|
test492@example.com,test,"test note",false,"test-label"
|
||||||
|
test493@example.com,test,"test note",false,"test-label"
|
||||||
|
test494@example.com,test,"test note",false,"test-label"
|
||||||
|
test495@example.com,test,"test note",false,"test-label"
|
||||||
|
test496@example.com,test,"test note",false,"test-label"
|
||||||
|
test497@example.com,test,"test note",false,"test-label"
|
||||||
|
test498@example.com,test,"test note",false,"test-label"
|
||||||
|
test499@example.com,test,"test note",false,"test-label"
|
||||||
|
test500@example.com,test,"test note",false,"test-label"
|
||||||
|
test501@example.com,test,"test note",false,"test-label"
|
|
|
@ -4,8 +4,8 @@ const fs = require('fs-extra');
|
||||||
const membersCSV = require('@tryghost/members-csv');
|
const membersCSV = require('@tryghost/members-csv');
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
const tpl = require('@tryghost/tpl');
|
const tpl = require('@tryghost/tpl');
|
||||||
|
|
||||||
const emailTemplate = require('./email-template');
|
const emailTemplate = require('./email-template');
|
||||||
|
const logging = require('@tryghost/logging');
|
||||||
|
|
||||||
const messages = {
|
const messages = {
|
||||||
filenameCollision: 'Filename already exists, please try again.'
|
filenameCollision: 'Filename already exists, please try again.'
|
||||||
|
@ -279,8 +279,9 @@ module.exports = class MembersCSVImporter {
|
||||||
* @param {String} config.user.email - calling user email
|
* @param {String} config.user.email - calling user email
|
||||||
* @param {Object} config.LabelModel - instance of Ghosts Label model
|
* @param {Object} config.LabelModel - instance of Ghosts Label model
|
||||||
* @param {Boolean} config.forceInline - allows to force performing imports not in a job (used in test environment)
|
* @param {Boolean} config.forceInline - allows to force performing imports not in a job (used in test environment)
|
||||||
|
* @param {{testImportThreshold: () => Promise<void>}} config.verificationTrigger
|
||||||
*/
|
*/
|
||||||
async process({pathToCSV, headerMapping, globalLabels, importLabel, user, LabelModel, forceInline}) {
|
async process({pathToCSV, headerMapping, globalLabels, importLabel, user, LabelModel, forceInline, verificationTrigger}) {
|
||||||
const meta = {};
|
const meta = {};
|
||||||
const job = await this.prepare(pathToCSV, headerMapping, globalLabels);
|
const job = await this.prepare(pathToCSV, headerMapping, globalLabels);
|
||||||
|
|
||||||
|
@ -289,6 +290,7 @@ module.exports = class MembersCSVImporter {
|
||||||
if ((job.batches <= 500 && !job.metadata.hasStripeData) || forceInline) {
|
if ((job.batches <= 500 && !job.metadata.hasStripeData) || forceInline) {
|
||||||
const result = await this.perform(job.filePath);
|
const result = await this.perform(job.filePath);
|
||||||
const importLabelModel = result.imported ? await LabelModel.findOne(importLabel) : null;
|
const importLabelModel = result.imported ? await LabelModel.findOne(importLabel) : null;
|
||||||
|
await verificationTrigger.testImportThreshold();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
meta: Object.assign(meta, {
|
meta: Object.assign(meta, {
|
||||||
|
@ -303,6 +305,7 @@ module.exports = class MembersCSVImporter {
|
||||||
const emailRecipient = user.email;
|
const emailRecipient = user.email;
|
||||||
this._addJob({
|
this._addJob({
|
||||||
job: async () => {
|
job: async () => {
|
||||||
|
try {
|
||||||
const result = await this.perform(job.filePath);
|
const result = await this.perform(job.filePath);
|
||||||
const importLabelModel = result.imported ? await LabelModel.findOne(importLabel) : null;
|
const importLabelModel = result.imported ? await LabelModel.findOne(importLabel) : null;
|
||||||
const emailContent = this.generateCompletionEmail(result, {
|
const emailContent = this.generateCompletionEmail(result, {
|
||||||
|
@ -311,7 +314,6 @@ module.exports = class MembersCSVImporter {
|
||||||
});
|
});
|
||||||
const errorCSV = this.generateErrorCSV(result);
|
const errorCSV = this.generateErrorCSV(result);
|
||||||
const emailSubject = result.imported > 0 ? 'Your member import is complete' : 'Your member import was unsuccessful';
|
const emailSubject = result.imported > 0 ? 'Your member import is complete' : 'Your member import was unsuccessful';
|
||||||
|
|
||||||
await this.sendErrorEmail({
|
await this.sendErrorEmail({
|
||||||
emailRecipient,
|
emailRecipient,
|
||||||
emailSubject,
|
emailSubject,
|
||||||
|
@ -319,6 +321,18 @@ module.exports = class MembersCSVImporter {
|
||||||
errorCSV,
|
errorCSV,
|
||||||
importLabel
|
importLabel
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
logging.error('Error in members import job');
|
||||||
|
logging.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Still check verification triggers in case of errors (e.g., email sending failed)
|
||||||
|
try {
|
||||||
|
await verificationTrigger.testImportThreshold();
|
||||||
|
} catch (e) {
|
||||||
|
logging.error('Error in members import job when testing import threshold');
|
||||||
|
logging.error(e);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
offloaded: false
|
offloaded: false
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tryghost/errors": "1.2.18",
|
"@tryghost/errors": "1.2.18",
|
||||||
|
"@tryghost/logging": "2.3.2",
|
||||||
"@tryghost/members-csv": "0.0.0",
|
"@tryghost/members-csv": "0.0.0",
|
||||||
"@tryghost/tpl": "0.1.19",
|
"@tryghost/tpl": "0.1.19",
|
||||||
"moment-timezone": "0.5.23"
|
"moment-timezone": "0.5.23"
|
||||||
|
|
|
@ -107,7 +107,10 @@ describe('Importer', function () {
|
||||||
user: {
|
user: {
|
||||||
email: 'test@example.com'
|
email: 'test@example.com'
|
||||||
},
|
},
|
||||||
LabelModel: LabelModelStub
|
LabelModel: LabelModelStub,
|
||||||
|
verificationTrigger: {
|
||||||
|
testImportThreshold: () => {}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
should.exist(result.meta);
|
should.exist(result.meta);
|
||||||
|
@ -153,7 +156,10 @@ describe('Importer', function () {
|
||||||
email: 'test@example.com'
|
email: 'test@example.com'
|
||||||
},
|
},
|
||||||
LabelModel: LabelModelStub,
|
LabelModel: LabelModelStub,
|
||||||
forceInline: true
|
forceInline: true,
|
||||||
|
verificationTrigger: {
|
||||||
|
testImportThreshold: () => {}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
should.exist(result.meta);
|
should.exist(result.meta);
|
||||||
|
|
Loading…
Add table
Reference in a new issue