0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Revert "Remove unnecessary references to ghostVersion"

This reverts commit 443ee369d2.
This commit is contained in:
Daniel Lockyer 2021-12-08 12:56:45 +00:00
parent 3a877253e6
commit 2d090b8b2a
5 changed files with 29 additions and 21 deletions

View file

@ -16,11 +16,14 @@ class MembersConfigProvider {
* @param {{get: (key: string) => any}} options.settingsCache
* @param {{get: (key: string) => any}} options.config
* @param {any} options.urlUtils
* @param {any} options.logging
* @param {{original: string}} options.ghostVersion
*/
constructor(options) {
this._settingsCache = options.settingsCache;
this._config = options.config;
this._urlUtils = options.urlUtils;
this._ghostVersion = options.ghostVersion;
}
/**

View file

@ -13,6 +13,7 @@ const labsService = require('../../../shared/labs');
const settingsCache = require('../../../shared/settings-cache');
const config = require('../../../shared/config');
const models = require('../../models');
const ghostVersion = require('@tryghost/version');
const _ = require('lodash');
const {GhostMailer} = require('../mail');
const jobsService = require('../jobs');
@ -34,7 +35,8 @@ const ghostMailer = new GhostMailer();
const membersConfig = new MembersConfigProvider({
config,
settingsCache,
urlUtils
urlUtils,
ghostVersion
});
let membersApi;

View file

@ -1,8 +1,10 @@
const settingsCache = require('../../../shared/settings-cache');
const ghostVersion = require('@tryghost/version');
const Notifications = require('./notifications');
const models = require('../../models');
module.exports.notifications = new Notifications({
settingsCache,
ghostVersion: ghostVersion.full,
SettingsModel: models.Settings
});

View file

@ -3,7 +3,6 @@ const semver = require('semver');
const Promise = require('bluebird');
const _ = require('lodash');
const errors = require('@tryghost/errors');
const ghostVersion = require('@tryghost/version');
const tpl = require('@tryghost/tpl');
const ObjectId = require('bson-objectid');
@ -17,10 +16,12 @@ class Notifications {
*
* @param {Object} options
* @param {Object} options.settingsCache - settings cache instance
* @param {String} options.ghostVersion - Ghost instance version in "full" format - major.minor.patch
* @param {Object} options.SettingsModel - Ghost's Setting model instance
*/
constructor({settingsCache, SettingsModel}) {
constructor({settingsCache, ghostVersion, SettingsModel}) {
this.settingsCache = settingsCache;
this.ghostVersion = ghostVersion;
this.SettingsModel = SettingsModel;
}
@ -73,7 +74,7 @@ class Notifications {
browse({user}) {
let allNotifications = this.fetchAllNotifications();
allNotifications = _.orderBy(allNotifications, 'addedAt', 'desc');
const blogVersion = ghostVersion.full.match(/^(\d+\.)(\d+\.)(\d+)/);
const blogVersion = this.ghostVersion.match(/^(\d+\.)(\d+\.)(\d+)/);
allNotifications = allNotifications.filter((notification) => {
if (notification.createdAtVersion && !this.wasSeen(notification, user)) {
@ -127,7 +128,7 @@ class Notifications {
location: 'bottom',
status: 'alert',
id: ObjectId().toHexString(),
createdAtVersion: ghostVersion.full
createdAtVersion: this.ghostVersion
};
const overrides = {

View file

@ -1,7 +1,6 @@
const should = require('should');
const sinon = require('sinon');
const ghostVersion = require('@tryghost/version');
const moment = require('moment');
const Notifications = require('../../../../../core/server/services/notifications/notifications');
const {owner} = require('../../../../utils/fixtures/context');
@ -14,9 +13,9 @@ describe('Notifications Service', function () {
get: sinon.fake.returns(existingNotifications)
};
sinon.stub(ghostVersion, 'full').value('4.1.0');
const notificationsSvc = new Notifications({
settingsCache
settingsCache,
ghostVersion: '4.1.0'
});
const {allNotifications, notificationsToAdd} = notificationsSvc.add({
@ -61,9 +60,9 @@ describe('Notifications Service', function () {
}])
};
sinon.stub(ghostVersion, 'full').value('4.1.0');
const notificationSvc = new Notifications({
settingsCache
settingsCache,
ghostVersion: '4.1.0'
});
const notifications = notificationSvc.browse({user: owner});
@ -90,9 +89,9 @@ describe('Notifications Service', function () {
}])
};
sinon.stub(ghostVersion, 'full').value('4.0.0');
const notificationSvc = new Notifications({
settingsCache
settingsCache,
ghostVersion: '4.0.0'
});
const notifications = notificationSvc.browse({user: owner});
@ -119,9 +118,9 @@ describe('Notifications Service', function () {
}])
};
sinon.stub(ghostVersion, 'full').value('3.0.0');
const notificationSvc = new Notifications({
settingsCache
settingsCache,
ghostVersion: '3.0.0'
});
const notifications = notificationSvc.browse({user: owner});
@ -148,9 +147,9 @@ describe('Notifications Service', function () {
}])
};
sinon.stub(ghostVersion, 'full').value('4.0.0');
const notificationSvc = new Notifications({
settingsCache
settingsCache,
ghostVersion: '4.0.0'
});
const notifications = notificationSvc.browse({user: owner});
@ -177,9 +176,9 @@ describe('Notifications Service', function () {
}])
};
sinon.stub(ghostVersion, 'full').value('5.0.0');
const notificationSvc = new Notifications({
settingsCache
settingsCache,
ghostVersion: '5.0.0'
});
const notifications = notificationSvc.browse({user: owner});
@ -219,9 +218,9 @@ describe('Notifications Service', function () {
}])
};
sinon.stub(ghostVersion, 'full').value('4.1.0');
const notificationSvc = new Notifications({
settingsCache
settingsCache,
ghostVersion: '4.1.0'
});
const notifications = notificationSvc.browse({user: owner});
@ -244,6 +243,7 @@ describe('Notifications Service', function () {
const notificationSvc = new Notifications({
settingsCache,
ghostVersion: '5.0.0',
SettingsModel: {
edit: settingsModelStub
}
@ -269,9 +269,9 @@ describe('Notifications Service', function () {
};
const settingsModelStub = sinon.stub().resolves();
sinon.stub(ghostVersion, 'full').value('5.0.0');
const notificationSvc = new Notifications({
settingsCache,
ghostVersion: '5.0.0',
SettingsModel: {
edit: settingsModelStub
}