mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Moved member importer declaration for readability
refs https://github.com/TryGhost/Team/issues/912 - Exposing a single method out of the service makes the API surface smaller - more readable. - Additionlally having a wrapping method in service will be helpful for other triggers that are going to be executed in later iterations
This commit is contained in:
parent
191f732115
commit
ec8b49ea42
3 changed files with 18 additions and 12 deletions
|
@ -479,7 +479,7 @@ module.exports = {
|
||||||
const pathToCSV = frame.file.path;
|
const pathToCSV = frame.file.path;
|
||||||
const headerMapping = frame.data.mapping;
|
const headerMapping = frame.data.mapping;
|
||||||
|
|
||||||
return membersService.importer.process({
|
return membersService.processImport({
|
||||||
pathToCSV,
|
pathToCSV,
|
||||||
headerMapping,
|
headerMapping,
|
||||||
globalLabels,
|
globalLabels,
|
||||||
|
|
|
@ -351,7 +351,7 @@ module.exports = {
|
||||||
const pathToCSV = frame.file.path;
|
const pathToCSV = frame.file.path;
|
||||||
const headerMapping = frame.data.mapping;
|
const headerMapping = frame.data.mapping;
|
||||||
|
|
||||||
return membersService.importer.process({
|
return membersService.processImport({
|
||||||
pathToCSV,
|
pathToCSV,
|
||||||
headerMapping,
|
headerMapping,
|
||||||
globalLabels,
|
globalLabels,
|
||||||
|
|
|
@ -48,6 +48,21 @@ function reconfigureMembersAPI() {
|
||||||
logging.error(err);
|
logging.error(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const membersImporter = new MembersCSVImporter({
|
||||||
|
storagePath: config.getContentPath('data'),
|
||||||
|
getTimezone: () => settingsCache.get('timezone'),
|
||||||
|
getMembersApi: () => membersApi,
|
||||||
|
sendEmail: ghostMailer.send.bind(ghostMailer),
|
||||||
|
isSet: labsService.isSet.bind(labsService),
|
||||||
|
addJob: jobsService.addJob.bind(jobsService),
|
||||||
|
knex: db.knex,
|
||||||
|
urlFor: urlUtils.urlFor.bind(urlUtils),
|
||||||
|
importThreshold: config.get('hostSettings.emailVerification.importThreshold')
|
||||||
|
});
|
||||||
|
|
||||||
|
const processImport = async (options) => {
|
||||||
|
return membersImporter.process(options);
|
||||||
|
};
|
||||||
|
|
||||||
const debouncedReconfigureMembersAPI = _.debounce(reconfigureMembersAPI, 600);
|
const debouncedReconfigureMembersAPI = _.debounce(reconfigureMembersAPI, 600);
|
||||||
|
|
||||||
|
@ -127,16 +142,7 @@ const membersService = {
|
||||||
|
|
||||||
stripeConnect: require('./stripe-connect'),
|
stripeConnect: require('./stripe-connect'),
|
||||||
|
|
||||||
importer: new MembersCSVImporter({
|
processImport: processImport,
|
||||||
storagePath: config.getContentPath('data'),
|
|
||||||
getTimezone: () => settingsCache.get('timezone'),
|
|
||||||
getMembersApi: () => membersApi,
|
|
||||||
sendEmail: ghostMailer.send.bind(ghostMailer),
|
|
||||||
isSet: labsService.isSet.bind(labsService),
|
|
||||||
addJob: jobsService.addJob.bind(jobsService),
|
|
||||||
knex: db.knex,
|
|
||||||
urlFor: urlUtils.urlFor.bind(urlUtils)
|
|
||||||
}),
|
|
||||||
|
|
||||||
stats: new MembersStats({
|
stats: new MembersStats({
|
||||||
db: db,
|
db: db,
|
||||||
|
|
Loading…
Add table
Reference in a new issue