mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Refactored labs dependency out of MembersCSVImporter
refs https://github.com/TryGhost/Team/issues/916 - The refactor was done follow the DI Constructor pattern and prepare module for extraction
This commit is contained in:
parent
c7edf256f6
commit
1eef1e9781
2 changed files with 12 additions and 7 deletions
|
@ -9,7 +9,6 @@ const urlUtils = require('../../../../shared/url-utils');
|
|||
const db = require('../../../data/db');
|
||||
const emailTemplate = require('./email-template');
|
||||
const jobsService = require('../../jobs');
|
||||
const labsService = require('../../../../shared/labs');
|
||||
|
||||
const messages = {
|
||||
filenameCollision: 'Filename already exists, please try again.',
|
||||
|
@ -22,13 +21,15 @@ module.exports = class MembersCSVImporter {
|
|||
* @param {string} config.storagePath - The path to store CSV's in before importing
|
||||
* @param {Object} settingsCache - An instance of the Ghost Settings Cache
|
||||
* @param {Object} ghostMailer - An instance of GhostMailer
|
||||
* @param {(string) => boolean} isSet - Method checking if specific feature is enabled
|
||||
* @param {() => Object} getMembersApi
|
||||
*/
|
||||
constructor(config, settingsCache, getMembersApi, ghostMailer) {
|
||||
constructor(config, settingsCache, getMembersApi, ghostMailer, isSet) {
|
||||
this._storagePath = config.storagePath;
|
||||
this._settingsCache = settingsCache;
|
||||
this._getMembersApi = getMembersApi;
|
||||
this._ghostMailer = ghostMailer;
|
||||
this._isSet = isSet;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,7 +157,7 @@ module.exports = class MembersCSVImporter {
|
|||
member_id: member.id
|
||||
}, options);
|
||||
} else if (row.complimentary_plan) {
|
||||
if (!labsService.isSet('multipleProducts')) {
|
||||
if (!this._isSet('multipleProducts')) {
|
||||
await membersApi.members.setComplimentarySubscription(member, options);
|
||||
} else if (!row.products) {
|
||||
await membersApi.members.update({
|
||||
|
@ -168,7 +169,7 @@ module.exports = class MembersCSVImporter {
|
|||
}
|
||||
}
|
||||
|
||||
if (labsService.isSet('multipleProducts')) {
|
||||
if (this._isSet('multipleProducts')) {
|
||||
if (row.products) {
|
||||
await membersApi.members.update({
|
||||
products: row.products
|
||||
|
|
|
@ -9,6 +9,7 @@ const createMembersApiInstance = require('./api');
|
|||
const createMembersSettingsInstance = require('./settings');
|
||||
const logging = require('@tryghost/logging');
|
||||
const urlUtils = require('../../../shared/url-utils');
|
||||
const labsService = require('../../../shared/labs');
|
||||
const settingsCache = require('../../../shared/settings-cache');
|
||||
const config = require('../../../shared/config');
|
||||
const ghostVersion = require('@tryghost/version');
|
||||
|
@ -126,9 +127,12 @@ const membersService = {
|
|||
stripeConnect: require('./stripe-connect'),
|
||||
|
||||
importer: new MembersCSVImporter({
|
||||
storagePath: config.getContentPath('data')},
|
||||
settingsCache, () => membersApi,
|
||||
ghostMailer
|
||||
storagePath: config.getContentPath('data')
|
||||
},
|
||||
settingsCache,
|
||||
() => membersApi,
|
||||
ghostMailer,
|
||||
labsService.isSet
|
||||
),
|
||||
|
||||
stats: new MembersStats({
|
||||
|
|
Loading…
Add table
Reference in a new issue