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:
Simon Backx 2022-11-28 18:22:10 +01:00 committed by GitHub
parent 2a28fa411b
commit 6e72767a50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 592 additions and 25 deletions

View File

@ -66,12 +66,7 @@ const membersImporter = new MembersCSVImporter({
});
const processImport = async (options) => {
const result = await membersImporter.process(options);
// Check whether all imports in last 30 days > threshold
await verificationTrigger.testImportThreshold();
return result;
return await membersImporter.process({...options, verificationTrigger});
};
const updateVerificationTrigger = () => {

View File

@ -7,6 +7,7 @@ const localUtils = require('./utils');
const config = require('../../../../core/shared/config');
const configUtils = require('../../../utils/configUtils');
const settingsCache = require('../../../../core/shared/settings-cache');
const models = require('../../../../core/server/models');
const {mockManager} = require('../../../utils/e2e-framework');
const assert = require('assert');
@ -14,6 +15,12 @@ const {_updateVerificationTrigger} = require('../../../../core/server/services/m
let request;
async function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
describe('Members Importer API', function () {
before(async function () {
await localUtils.startGhost();
@ -302,4 +309,46 @@ describe('Members Importer API', function () {
// Don't send another email
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'
});
});
});

View File

@ -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"
1 email name note subscribed_to_emails labels
2 test1@example.com test test note false test-label
3 test2@example.com test test note false test-label
4 test3@example.com test test note false test-label
5 test4@example.com test test note false test-label
6 test5@example.com test test note false test-label
7 test6@example.com test test note false test-label
8 test7@example.com test test note false test-label
9 test8@example.com test test note false test-label
10 test9@example.com test test note false test-label
11 test10@example.com test test note false test-label
12 test11@example.com test test note false test-label
13 test12@example.com test test note false test-label
14 test13@example.com test test note false test-label
15 test14@example.com test test note false test-label
16 test15@example.com test test note false test-label
17 test16@example.com test test note false test-label
18 test17@example.com test test note false test-label
19 test18@example.com test test note false test-label
20 test19@example.com test test note false test-label
21 test20@example.com test test note false test-label
22 test21@example.com test test note false test-label
23 test22@example.com test test note false test-label
24 test23@example.com test test note false test-label
25 test24@example.com test test note false test-label
26 test25@example.com test test note false test-label
27 test26@example.com test test note false test-label
28 test27@example.com test test note false test-label
29 test28@example.com test test note false test-label
30 test29@example.com test test note false test-label
31 test30@example.com test test note false test-label
32 test31@example.com test test note false test-label
33 test32@example.com test test note false test-label
34 test33@example.com test test note false test-label
35 test34@example.com test test note false test-label
36 test35@example.com test test note false test-label
37 test36@example.com test test note false test-label
38 test37@example.com test test note false test-label
39 test38@example.com test test note false test-label
40 test39@example.com test test note false test-label
41 test40@example.com test test note false test-label
42 test41@example.com test test note false test-label
43 test42@example.com test test note false test-label
44 test43@example.com test test note false test-label
45 test44@example.com test test note false test-label
46 test45@example.com test test note false test-label
47 test46@example.com test test note false test-label
48 test47@example.com test test note false test-label
49 test48@example.com test test note false test-label
50 test49@example.com test test note false test-label
51 test50@example.com test test note false test-label
52 test51@example.com test test note false test-label
53 test52@example.com test test note false test-label
54 test53@example.com test test note false test-label
55 test54@example.com test test note false test-label
56 test55@example.com test test note false test-label
57 test56@example.com test test note false test-label
58 test57@example.com test test note false test-label
59 test58@example.com test test note false test-label
60 test59@example.com test test note false test-label
61 test60@example.com test test note false test-label
62 test61@example.com test test note false test-label
63 test62@example.com test test note false test-label
64 test63@example.com test test note false test-label
65 test64@example.com test test note false test-label
66 test65@example.com test test note false test-label
67 test66@example.com test test note false test-label
68 test67@example.com test test note false test-label
69 test68@example.com test test note false test-label
70 test69@example.com test test note false test-label
71 test70@example.com test test note false test-label
72 test71@example.com test test note false test-label
73 test72@example.com test test note false test-label
74 test73@example.com test test note false test-label
75 test74@example.com test test note false test-label
76 test75@example.com test test note false test-label
77 test76@example.com test test note false test-label
78 test77@example.com test test note false test-label
79 test78@example.com test test note false test-label
80 test79@example.com test test note false test-label
81 test80@example.com test test note false test-label
82 test81@example.com test test note false test-label
83 test82@example.com test test note false test-label
84 test83@example.com test test note false test-label
85 test84@example.com test test note false test-label
86 test85@example.com test test note false test-label
87 test86@example.com test test note false test-label
88 test87@example.com test test note false test-label
89 test88@example.com test test note false test-label
90 test89@example.com test test note false test-label
91 test90@example.com test test note false test-label
92 test91@example.com test test note false test-label
93 test92@example.com test test note false test-label
94 test93@example.com test test note false test-label
95 test94@example.com test test note false test-label
96 test95@example.com test test note false test-label
97 test96@example.com test test note false test-label
98 test97@example.com test test note false test-label
99 test98@example.com test test note false test-label
100 test99@example.com test test note false test-label
101 test100@example.com test test note false test-label
102 test101@example.com test test note false test-label
103 test102@example.com test test note false test-label
104 test103@example.com test test note false test-label
105 test104@example.com test test note false test-label
106 test105@example.com test test note false test-label
107 test106@example.com test test note false test-label
108 test107@example.com test test note false test-label
109 test108@example.com test test note false test-label
110 test109@example.com test test note false test-label
111 test110@example.com test test note false test-label
112 test111@example.com test test note false test-label
113 test112@example.com test test note false test-label
114 test113@example.com test test note false test-label
115 test114@example.com test test note false test-label
116 test115@example.com test test note false test-label
117 test116@example.com test test note false test-label
118 test117@example.com test test note false test-label
119 test118@example.com test test note false test-label
120 test119@example.com test test note false test-label
121 test120@example.com test test note false test-label
122 test121@example.com test test note false test-label
123 test122@example.com test test note false test-label
124 test123@example.com test test note false test-label
125 test124@example.com test test note false test-label
126 test125@example.com test test note false test-label
127 test126@example.com test test note false test-label
128 test127@example.com test test note false test-label
129 test128@example.com test test note false test-label
130 test129@example.com test test note false test-label
131 test130@example.com test test note false test-label
132 test131@example.com test test note false test-label
133 test132@example.com test test note false test-label
134 test133@example.com test test note false test-label
135 test134@example.com test test note false test-label
136 test135@example.com test test note false test-label
137 test136@example.com test test note false test-label
138 test137@example.com test test note false test-label
139 test138@example.com test test note false test-label
140 test139@example.com test test note false test-label
141 test140@example.com test test note false test-label
142 test141@example.com test test note false test-label
143 test142@example.com test test note false test-label
144 test143@example.com test test note false test-label
145 test144@example.com test test note false test-label
146 test145@example.com test test note false test-label
147 test146@example.com test test note false test-label
148 test147@example.com test test note false test-label
149 test148@example.com test test note false test-label
150 test149@example.com test test note false test-label
151 test150@example.com test test note false test-label
152 test151@example.com test test note false test-label
153 test152@example.com test test note false test-label
154 test153@example.com test test note false test-label
155 test154@example.com test test note false test-label
156 test155@example.com test test note false test-label
157 test156@example.com test test note false test-label
158 test157@example.com test test note false test-label
159 test158@example.com test test note false test-label
160 test159@example.com test test note false test-label
161 test160@example.com test test note false test-label
162 test161@example.com test test note false test-label
163 test162@example.com test test note false test-label
164 test163@example.com test test note false test-label
165 test164@example.com test test note false test-label
166 test165@example.com test test note false test-label
167 test166@example.com test test note false test-label
168 test167@example.com test test note false test-label
169 test168@example.com test test note false test-label
170 test169@example.com test test note false test-label
171 test170@example.com test test note false test-label
172 test171@example.com test test note false test-label
173 test172@example.com test test note false test-label
174 test173@example.com test test note false test-label
175 test174@example.com test test note false test-label
176 test175@example.com test test note false test-label
177 test176@example.com test test note false test-label
178 test177@example.com test test note false test-label
179 test178@example.com test test note false test-label
180 test179@example.com test test note false test-label
181 test180@example.com test test note false test-label
182 test181@example.com test test note false test-label
183 test182@example.com test test note false test-label
184 test183@example.com test test note false test-label
185 test184@example.com test test note false test-label
186 test185@example.com test test note false test-label
187 test186@example.com test test note false test-label
188 test187@example.com test test note false test-label
189 test188@example.com test test note false test-label
190 test189@example.com test test note false test-label
191 test190@example.com test test note false test-label
192 test191@example.com test test note false test-label
193 test192@example.com test test note false test-label
194 test193@example.com test test note false test-label
195 test194@example.com test test note false test-label
196 test195@example.com test test note false test-label
197 test196@example.com test test note false test-label
198 test197@example.com test test note false test-label
199 test198@example.com test test note false test-label
200 test199@example.com test test note false test-label
201 test200@example.com test test note false test-label
202 test201@example.com test test note false test-label
203 test202@example.com test test note false test-label
204 test203@example.com test test note false test-label
205 test204@example.com test test note false test-label
206 test205@example.com test test note false test-label
207 test206@example.com test test note false test-label
208 test207@example.com test test note false test-label
209 test208@example.com test test note false test-label
210 test209@example.com test test note false test-label
211 test210@example.com test test note false test-label
212 test211@example.com test test note false test-label
213 test212@example.com test test note false test-label
214 test213@example.com test test note false test-label
215 test214@example.com test test note false test-label
216 test215@example.com test test note false test-label
217 test216@example.com test test note false test-label
218 test217@example.com test test note false test-label
219 test218@example.com test test note false test-label
220 test219@example.com test test note false test-label
221 test220@example.com test test note false test-label
222 test221@example.com test test note false test-label
223 test222@example.com test test note false test-label
224 test223@example.com test test note false test-label
225 test224@example.com test test note false test-label
226 test225@example.com test test note false test-label
227 test226@example.com test test note false test-label
228 test227@example.com test test note false test-label
229 test228@example.com test test note false test-label
230 test229@example.com test test note false test-label
231 test230@example.com test test note false test-label
232 test231@example.com test test note false test-label
233 test232@example.com test test note false test-label
234 test233@example.com test test note false test-label
235 test234@example.com test test note false test-label
236 test235@example.com test test note false test-label
237 test236@example.com test test note false test-label
238 test237@example.com test test note false test-label
239 test238@example.com test test note false test-label
240 test239@example.com test test note false test-label
241 test240@example.com test test note false test-label
242 test241@example.com test test note false test-label
243 test242@example.com test test note false test-label
244 test243@example.com test test note false test-label
245 test244@example.com test test note false test-label
246 test245@example.com test test note false test-label
247 test246@example.com test test note false test-label
248 test247@example.com test test note false test-label
249 test248@example.com test test note false test-label
250 test249@example.com test test note false test-label
251 test250@example.com test test note false test-label
252 test251@example.com test test note false test-label
253 test252@example.com test test note false test-label
254 test253@example.com test test note false test-label
255 test254@example.com test test note false test-label
256 test255@example.com test test note false test-label
257 test256@example.com test test note false test-label
258 test257@example.com test test note false test-label
259 test258@example.com test test note false test-label
260 test259@example.com test test note false test-label
261 test260@example.com test test note false test-label
262 test261@example.com test test note false test-label
263 test262@example.com test test note false test-label
264 test263@example.com test test note false test-label
265 test264@example.com test test note false test-label
266 test265@example.com test test note false test-label
267 test266@example.com test test note false test-label
268 test267@example.com test test note false test-label
269 test268@example.com test test note false test-label
270 test269@example.com test test note false test-label
271 test270@example.com test test note false test-label
272 test271@example.com test test note false test-label
273 test272@example.com test test note false test-label
274 test273@example.com test test note false test-label
275 test274@example.com test test note false test-label
276 test275@example.com test test note false test-label
277 test276@example.com test test note false test-label
278 test277@example.com test test note false test-label
279 test278@example.com test test note false test-label
280 test279@example.com test test note false test-label
281 test280@example.com test test note false test-label
282 test281@example.com test test note false test-label
283 test282@example.com test test note false test-label
284 test283@example.com test test note false test-label
285 test284@example.com test test note false test-label
286 test285@example.com test test note false test-label
287 test286@example.com test test note false test-label
288 test287@example.com test test note false test-label
289 test288@example.com test test note false test-label
290 test289@example.com test test note false test-label
291 test290@example.com test test note false test-label
292 test291@example.com test test note false test-label
293 test292@example.com test test note false test-label
294 test293@example.com test test note false test-label
295 test294@example.com test test note false test-label
296 test295@example.com test test note false test-label
297 test296@example.com test test note false test-label
298 test297@example.com test test note false test-label
299 test298@example.com test test note false test-label
300 test299@example.com test test note false test-label
301 test300@example.com test test note false test-label
302 test301@example.com test test note false test-label
303 test302@example.com test test note false test-label
304 test303@example.com test test note false test-label
305 test304@example.com test test note false test-label
306 test305@example.com test test note false test-label
307 test306@example.com test test note false test-label
308 test307@example.com test test note false test-label
309 test308@example.com test test note false test-label
310 test309@example.com test test note false test-label
311 test310@example.com test test note false test-label
312 test311@example.com test test note false test-label
313 test312@example.com test test note false test-label
314 test313@example.com test test note false test-label
315 test314@example.com test test note false test-label
316 test315@example.com test test note false test-label
317 test316@example.com test test note false test-label
318 test317@example.com test test note false test-label
319 test318@example.com test test note false test-label
320 test319@example.com test test note false test-label
321 test320@example.com test test note false test-label
322 test321@example.com test test note false test-label
323 test322@example.com test test note false test-label
324 test323@example.com test test note false test-label
325 test324@example.com test test note false test-label
326 test325@example.com test test note false test-label
327 test326@example.com test test note false test-label
328 test327@example.com test test note false test-label
329 test328@example.com test test note false test-label
330 test329@example.com test test note false test-label
331 test330@example.com test test note false test-label
332 test331@example.com test test note false test-label
333 test332@example.com test test note false test-label
334 test333@example.com test test note false test-label
335 test334@example.com test test note false test-label
336 test335@example.com test test note false test-label
337 test336@example.com test test note false test-label
338 test337@example.com test test note false test-label
339 test338@example.com test test note false test-label
340 test339@example.com test test note false test-label
341 test340@example.com test test note false test-label
342 test341@example.com test test note false test-label
343 test342@example.com test test note false test-label
344 test343@example.com test test note false test-label
345 test344@example.com test test note false test-label
346 test345@example.com test test note false test-label
347 test346@example.com test test note false test-label
348 test347@example.com test test note false test-label
349 test348@example.com test test note false test-label
350 test349@example.com test test note false test-label
351 test350@example.com test test note false test-label
352 test351@example.com test test note false test-label
353 test352@example.com test test note false test-label
354 test353@example.com test test note false test-label
355 test354@example.com test test note false test-label
356 test355@example.com test test note false test-label
357 test356@example.com test test note false test-label
358 test357@example.com test test note false test-label
359 test358@example.com test test note false test-label
360 test359@example.com test test note false test-label
361 test360@example.com test test note false test-label
362 test361@example.com test test note false test-label
363 test362@example.com test test note false test-label
364 test363@example.com test test note false test-label
365 test364@example.com test test note false test-label
366 test365@example.com test test note false test-label
367 test366@example.com test test note false test-label
368 test367@example.com test test note false test-label
369 test368@example.com test test note false test-label
370 test369@example.com test test note false test-label
371 test370@example.com test test note false test-label
372 test371@example.com test test note false test-label
373 test372@example.com test test note false test-label
374 test373@example.com test test note false test-label
375 test374@example.com test test note false test-label
376 test375@example.com test test note false test-label
377 test376@example.com test test note false test-label
378 test377@example.com test test note false test-label
379 test378@example.com test test note false test-label
380 test379@example.com test test note false test-label
381 test380@example.com test test note false test-label
382 test381@example.com test test note false test-label
383 test382@example.com test test note false test-label
384 test383@example.com test test note false test-label
385 test384@example.com test test note false test-label
386 test385@example.com test test note false test-label
387 test386@example.com test test note false test-label
388 test387@example.com test test note false test-label
389 test388@example.com test test note false test-label
390 test389@example.com test test note false test-label
391 test390@example.com test test note false test-label
392 test391@example.com test test note false test-label
393 test392@example.com test test note false test-label
394 test393@example.com test test note false test-label
395 test394@example.com test test note false test-label
396 test395@example.com test test note false test-label
397 test396@example.com test test note false test-label
398 test397@example.com test test note false test-label
399 test398@example.com test test note false test-label
400 test399@example.com test test note false test-label
401 test400@example.com test test note false test-label
402 test401@example.com test test note false test-label
403 test402@example.com test test note false test-label
404 test403@example.com test test note false test-label
405 test404@example.com test test note false test-label
406 test405@example.com test test note false test-label
407 test406@example.com test test note false test-label
408 test407@example.com test test note false test-label
409 test408@example.com test test note false test-label
410 test409@example.com test test note false test-label
411 test410@example.com test test note false test-label
412 test411@example.com test test note false test-label
413 test412@example.com test test note false test-label
414 test413@example.com test test note false test-label
415 test414@example.com test test note false test-label
416 test415@example.com test test note false test-label
417 test416@example.com test test note false test-label
418 test417@example.com test test note false test-label
419 test418@example.com test test note false test-label
420 test419@example.com test test note false test-label
421 test420@example.com test test note false test-label
422 test421@example.com test test note false test-label
423 test422@example.com test test note false test-label
424 test423@example.com test test note false test-label
425 test424@example.com test test note false test-label
426 test425@example.com test test note false test-label
427 test426@example.com test test note false test-label
428 test427@example.com test test note false test-label
429 test428@example.com test test note false test-label
430 test429@example.com test test note false test-label
431 test430@example.com test test note false test-label
432 test431@example.com test test note false test-label
433 test432@example.com test test note false test-label
434 test433@example.com test test note false test-label
435 test434@example.com test test note false test-label
436 test435@example.com test test note false test-label
437 test436@example.com test test note false test-label
438 test437@example.com test test note false test-label
439 test438@example.com test test note false test-label
440 test439@example.com test test note false test-label
441 test440@example.com test test note false test-label
442 test441@example.com test test note false test-label
443 test442@example.com test test note false test-label
444 test443@example.com test test note false test-label
445 test444@example.com test test note false test-label
446 test445@example.com test test note false test-label
447 test446@example.com test test note false test-label
448 test447@example.com test test note false test-label
449 test448@example.com test test note false test-label
450 test449@example.com test test note false test-label
451 test450@example.com test test note false test-label
452 test451@example.com test test note false test-label
453 test452@example.com test test note false test-label
454 test453@example.com test test note false test-label
455 test454@example.com test test note false test-label
456 test455@example.com test test note false test-label
457 test456@example.com test test note false test-label
458 test457@example.com test test note false test-label
459 test458@example.com test test note false test-label
460 test459@example.com test test note false test-label
461 test460@example.com test test note false test-label
462 test461@example.com test test note false test-label
463 test462@example.com test test note false test-label
464 test463@example.com test test note false test-label
465 test464@example.com test test note false test-label
466 test465@example.com test test note false test-label
467 test466@example.com test test note false test-label
468 test467@example.com test test note false test-label
469 test468@example.com test test note false test-label
470 test469@example.com test test note false test-label
471 test470@example.com test test note false test-label
472 test471@example.com test test note false test-label
473 test472@example.com test test note false test-label
474 test473@example.com test test note false test-label
475 test474@example.com test test note false test-label
476 test475@example.com test test note false test-label
477 test476@example.com test test note false test-label
478 test477@example.com test test note false test-label
479 test478@example.com test test note false test-label
480 test479@example.com test test note false test-label
481 test480@example.com test test note false test-label
482 test481@example.com test test note false test-label
483 test482@example.com test test note false test-label
484 test483@example.com test test note false test-label
485 test484@example.com test test note false test-label
486 test485@example.com test test note false test-label
487 test486@example.com test test note false test-label
488 test487@example.com test test note false test-label
489 test488@example.com test test note false test-label
490 test489@example.com test test note false test-label
491 test490@example.com test test note false test-label
492 test491@example.com test test note false test-label
493 test492@example.com test test note false test-label
494 test493@example.com test test note false test-label
495 test494@example.com test test note false test-label
496 test495@example.com test test note false test-label
497 test496@example.com test test note false test-label
498 test497@example.com test test note false test-label
499 test498@example.com test test note false test-label
500 test499@example.com test test note false test-label
501 test500@example.com test test note false test-label
502 test501@example.com test test note false test-label

View File

@ -4,8 +4,8 @@ const fs = require('fs-extra');
const membersCSV = require('@tryghost/members-csv');
const errors = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');
const emailTemplate = require('./email-template');
const logging = require('@tryghost/logging');
const messages = {
filenameCollision: 'Filename already exists, please try again.'
@ -279,8 +279,9 @@ module.exports = class MembersCSVImporter {
* @param {String} config.user.email - calling user email
* @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 {{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 job = await this.prepare(pathToCSV, headerMapping, globalLabels);
@ -289,6 +290,7 @@ module.exports = class MembersCSVImporter {
if ((job.batches <= 500 && !job.metadata.hasStripeData) || forceInline) {
const result = await this.perform(job.filePath);
const importLabelModel = result.imported ? await LabelModel.findOne(importLabel) : null;
await verificationTrigger.testImportThreshold();
return {
meta: Object.assign(meta, {
@ -303,22 +305,34 @@ module.exports = class MembersCSVImporter {
const emailRecipient = user.email;
this._addJob({
job: async () => {
const result = await this.perform(job.filePath);
const importLabelModel = result.imported ? await LabelModel.findOne(importLabel) : null;
const emailContent = this.generateCompletionEmail(result, {
emailRecipient,
importLabel: importLabelModel ? importLabelModel.toJSON() : null
});
const errorCSV = this.generateErrorCSV(result);
const emailSubject = result.imported > 0 ? 'Your member import is complete' : 'Your member import was unsuccessful';
try {
const result = await this.perform(job.filePath);
const importLabelModel = result.imported ? await LabelModel.findOne(importLabel) : null;
const emailContent = this.generateCompletionEmail(result, {
emailRecipient,
importLabel: importLabelModel ? importLabelModel.toJSON() : null
});
const errorCSV = this.generateErrorCSV(result);
const emailSubject = result.imported > 0 ? 'Your member import is complete' : 'Your member import was unsuccessful';
await this.sendErrorEmail({
emailRecipient,
emailSubject,
emailContent,
errorCSV,
importLabel
});
} catch (e) {
logging.error('Error in members import job');
logging.error(e);
}
await this.sendErrorEmail({
emailRecipient,
emailSubject,
emailContent,
errorCSV,
importLabel
});
// 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
});

View File

@ -24,6 +24,7 @@
},
"dependencies": {
"@tryghost/errors": "1.2.18",
"@tryghost/logging": "2.3.2",
"@tryghost/members-csv": "0.0.0",
"@tryghost/tpl": "0.1.19",
"moment-timezone": "0.5.23"

View File

@ -107,7 +107,10 @@ describe('Importer', function () {
user: {
email: 'test@example.com'
},
LabelModel: LabelModelStub
LabelModel: LabelModelStub,
verificationTrigger: {
testImportThreshold: () => {}
}
});
should.exist(result.meta);
@ -153,7 +156,10 @@ describe('Importer', function () {
email: 'test@example.com'
},
LabelModel: LabelModelStub,
forceInline: true
forceInline: true,
verificationTrigger: {
testImportThreshold: () => {}
}
});
should.exist(result.meta);