mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 21:33:24 +03:00
Skipped notificaiton processing when no valid data
refs https://github.com/TryGhost/Team/issues/754 - When there are no message objects coming from the external update check service in the response there is no need to continue to process the data and fire off unneeded queries
This commit is contained in:
parent
65d863d74b
commit
bc3ea7e12e
@ -283,7 +283,7 @@ class UpdateCheckService {
|
||||
* @return {Promise}
|
||||
*/
|
||||
async createCustomNotification(notification) {
|
||||
if (!notification) {
|
||||
if (!notification || !notification.messages || notification.messages.length === 0) {
|
||||
debug(`Skipping notification creation as there are no messages to process`);
|
||||
return;
|
||||
}
|
||||
|
@ -326,5 +326,47 @@ describe('Update Check', function () {
|
||||
notificationsAPIAddStub.calledOnce.should.equal(true);
|
||||
notificationsAPIAddStub.args[0][0].notifications.length.should.equal(1);
|
||||
});
|
||||
|
||||
it('not create a notification if the check response has no messages', async function () {
|
||||
const notificationsAPIAddStub = sinon.stub().resolves();
|
||||
|
||||
const updateCheckService = new UpdateCheckService({
|
||||
api: {
|
||||
settings: {
|
||||
read: settingsStub,
|
||||
edit: settingsStub
|
||||
},
|
||||
users: {
|
||||
browse: sinon.stub().resolves({
|
||||
users: [{
|
||||
roles: [{
|
||||
name: 'Owner'
|
||||
}]
|
||||
}]
|
||||
})
|
||||
},
|
||||
posts: {
|
||||
browse: sinon.stub().resolves()
|
||||
},
|
||||
notifications: {
|
||||
add: notificationsAPIAddStub
|
||||
}
|
||||
},
|
||||
config: {
|
||||
siteUrl: 'https://localhost:2368/test'
|
||||
},
|
||||
i18n: i18nStub,
|
||||
logging: loggingStub,
|
||||
request: sinon.stub().resolves({
|
||||
body: {
|
||||
notifications: []
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
await updateCheckService.check();
|
||||
|
||||
notificationsAPIAddStub.calledOnce.should.equal(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user