mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
2d92e98392
refs https://github.com/TryGhost/Toolbox/issues/280 - When passing the sendEmail parameter with a boutnd 'send' method the e2e tests were failing becuase mock mailer did not pick up the send method. Using this slightly more verbose implementation as it "just works". Could be rewritten into something nicer if there's such a need in the future
26 lines
1.3 KiB
JavaScript
26 lines
1.3 KiB
JavaScript
const APIVersionCompatibilityService = require('@tryghost/api-version-compatibility-service');
|
|
const VersionNotificationsDataService = require('@tryghost/version-notifications-data-service');
|
|
const {GhostMailer} = require('../mail');
|
|
const settingsService = require('../../services/settings');
|
|
const models = require('../../models');
|
|
|
|
const init = () => {
|
|
const ghostMailer = new GhostMailer();
|
|
const versionNotificationsDataService = new VersionNotificationsDataService({
|
|
UserModel: models.User,
|
|
settingsService: settingsService.getSettingsBREADServiceInstance()
|
|
});
|
|
|
|
this.APIVersionCompatibilityServiceInstance = new APIVersionCompatibilityService({
|
|
sendEmail: (options) => {
|
|
// NOTE: not using bind here because mockMailer is having trouble mocking bound methods
|
|
return ghostMailer.send(options);
|
|
},
|
|
fetchEmailsToNotify: versionNotificationsDataService.getNotificationEmails.bind(versionNotificationsDataService),
|
|
fetchHandled: versionNotificationsDataService.fetchNotification.bind(versionNotificationsDataService),
|
|
saveHandled: versionNotificationsDataService.saveNotification.bind(versionNotificationsDataService)
|
|
});
|
|
};
|
|
|
|
module.exports.APIVersionCompatibilityServiceInstance;
|
|
module.exports.init = init;
|