0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server/services/api-version-compatibility/index.js

27 lines
1.3 KiB
JavaScript
Raw Normal View History

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;