0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Revert "Disabled version compatibility emails temporarily"

This reverts commit 9a0d143fb1

- main is now a precursor of 5.0 which should have email notification turned on
- had to add missing `err` in the errorHandler middleware as it was not triggering the versionMissmatchHandler otherwise
This commit is contained in:
Naz 2022-05-03 15:45:23 +08:00 committed by naz
parent 734ef66e6c
commit 3d397bb5f1
2 changed files with 17 additions and 23 deletions

View file

@ -1,16 +1,15 @@
const APIVersionCompatibilityService = require('@tryghost/api-version-compatibility-service');
const VersionNotificationsDataService = require('@tryghost/version-notifications-data-service');
const versionMismatchHandler = require('@tryghost/mw-api-version-mismatch');
// const {GhostMailer} = require('../mail');
const ghostVersion = require('@tryghost/version');
const {GhostMailer} = require('../mail');
const settingsService = require('../../services/settings');
const models = require('../../models');
const logging = require('@tryghost/logging');
const ghostVersion = require('@tryghost/version');
let serviceInstance;
const init = () => {
//const ghostMailer = new GhostMailer();
const ghostMailer = new GhostMailer();
const versionNotificationsDataService = new VersionNotificationsDataService({
UserModel: models.User,
settingsService: settingsService.getSettingsBREADServiceInstance()
@ -19,9 +18,7 @@ const init = () => {
serviceInstance = new APIVersionCompatibilityService({
sendEmail: (options) => {
// NOTE: not using bind here because mockMailer is having trouble mocking bound methods
//return ghostMailer.send(options);
// For now log a warning, rather than sending an email
logging.warn(options.html);
return ghostMailer.send(options);
},
fetchEmailsToNotify: versionNotificationsDataService.getNotificationEmails.bind(versionNotificationsDataService),
fetchHandled: versionNotificationsDataService.fetchNotification.bind(versionNotificationsDataService),
@ -29,8 +26,8 @@ const init = () => {
});
};
module.exports.errorHandler = (req, res, next) => {
return versionMismatchHandler(serviceInstance)(req, res, next);
module.exports.errorHandler = (err, req, res, next) => {
return versionMismatchHandler(serviceInstance)(err, req, res, next);
};
module.exports.contentVersion = (req, res, next) => {

View file

@ -101,12 +101,11 @@ describe('API Versioning', function () {
}]
});
// temporarily disable email sending
mockManager.assert.sentEmailCount(0);
// mockManager.assert.sentEmail({
// subject: 'Attention required: Your Zapier 1.3 integration has failed',
// to: 'jbloggs@example.com'
// });
mockManager.assert.sentEmailCount(1);
mockManager.assert.sentEmail({
subject: 'Attention required: Your Zapier 1.3 integration has failed',
to: 'jbloggs@example.com'
});
});
it('responds with error and sends email ONCE when requested version is BEHIND and CANNOT respond multiple times', async function () {
@ -126,12 +125,11 @@ describe('API Versioning', function () {
}]
});
// temporarily disable email sending
mockManager.assert.sentEmailCount(0);
// mockManager.assert.sentEmail({
// subject: 'Attention required: Your Zapier 1.4 integration has failed',
// to: 'jbloggs@example.com'
// });
mockManager.assert.sentEmailCount(1);
mockManager.assert.sentEmail({
subject: 'Attention required: Your Zapier 1.4 integration has failed',
to: 'jbloggs@example.com'
});
await agentAdminAPI
.get('removed_endpoint')
@ -149,8 +147,7 @@ describe('API Versioning', function () {
}]
});
// temporarily disable email sending
mockManager.assert.sentEmailCount(0);
mockManager.assert.sentEmailCount(1);
});
it('responds with 404 error when the resource cannot be found', async function () {