mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-07 11:30:55 +03:00
Remove i18n dependency from notifications service
refs https://github.com/TryGhost/Ghost/issues/13380 - The i18n package is deprecated. It is being replaced with the tpl package.
This commit is contained in:
parent
f8dd0b3d56
commit
84118068c8
@ -1,12 +1,10 @@
|
|||||||
const settingsCache = require('../../../shared/settings-cache');
|
const settingsCache = require('../../../shared/settings-cache');
|
||||||
const i18n = require('../../../shared/i18n');
|
|
||||||
const ghostVersion = require('@tryghost/version');
|
const ghostVersion = require('@tryghost/version');
|
||||||
const Notifications = require('./notifications');
|
const Notifications = require('./notifications');
|
||||||
const models = require('../../models');
|
const models = require('../../models');
|
||||||
|
|
||||||
module.exports.notifications = new Notifications({
|
module.exports.notifications = new Notifications({
|
||||||
settingsCache,
|
settingsCache,
|
||||||
i18n,
|
|
||||||
ghostVersion,
|
ghostVersion,
|
||||||
SettingsModel: models.Settings
|
SettingsModel: models.Settings
|
||||||
});
|
});
|
||||||
|
@ -3,21 +3,25 @@ const semver = require('semver');
|
|||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
|
const tpl = require('@tryghost/tpl');
|
||||||
const ObjectId = require('bson-objectid');
|
const ObjectId = require('bson-objectid');
|
||||||
|
|
||||||
|
const messages = {
|
||||||
|
noPermissionToDismissNotif: 'You do not have permission to dismiss this notification.',
|
||||||
|
notificationDoesNotExist: 'Notification does not exist.'
|
||||||
|
};
|
||||||
|
|
||||||
class Notifications {
|
class Notifications {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
* @param {Object} options.settingsCache - settings cache instance
|
* @param {Object} options.settingsCache - settings cache instance
|
||||||
* @param {Object} options.i18n - i18n instance
|
|
||||||
* @param {Object} options.ghostVersion
|
* @param {Object} options.ghostVersion
|
||||||
* @param {String} options.ghostVersion.full - Ghost instance version in "full" format - major.minor.patch
|
* @param {String} options.ghostVersion.full - Ghost instance version in "full" format - major.minor.patch
|
||||||
* @param {Object} options.SettingsModel - Ghost's Setting model instance
|
* @param {Object} options.SettingsModel - Ghost's Setting model instance
|
||||||
*/
|
*/
|
||||||
constructor({settingsCache, i18n, ghostVersion, SettingsModel}) {
|
constructor({settingsCache, ghostVersion, SettingsModel}) {
|
||||||
this.settingsCache = settingsCache;
|
this.settingsCache = settingsCache;
|
||||||
this.i18n = i18n;
|
|
||||||
this.ghostVersion = ghostVersion;
|
this.ghostVersion = ghostVersion;
|
||||||
this.SettingsModel = SettingsModel;
|
this.SettingsModel = SettingsModel;
|
||||||
}
|
}
|
||||||
@ -195,13 +199,13 @@ class Notifications {
|
|||||||
|
|
||||||
if (notificationToMarkAsSeenIndex > -1 && !notificationToMarkAsSeen.dismissible) {
|
if (notificationToMarkAsSeenIndex > -1 && !notificationToMarkAsSeen.dismissible) {
|
||||||
return Promise.reject(new errors.NoPermissionError({
|
return Promise.reject(new errors.NoPermissionError({
|
||||||
message: this.i18n.t('errors.api.notifications.noPermissionToDismissNotif')
|
message: tpl(messages.noPermissionToDismissNotif)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notificationToMarkAsSeenIndex < 0) {
|
if (notificationToMarkAsSeenIndex < 0) {
|
||||||
return Promise.reject(new errors.NotFoundError({
|
return Promise.reject(new errors.NotFoundError({
|
||||||
message: this.i18n.t('errors.api.notifications.notificationDoesNotExist')
|
message: tpl(messages.notificationDoesNotExist)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user