mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Removed urlFor parameter from UpdateCheckService
refs https://github.com/TryGhost/Team/issues/728 - This is continuation of the previous commit. TLDR: Passing only the necessary API endpoint function makes it easier to reason about what dependencies the UpdateCheckService has to deal with - Substituted a parameter with already existing 'siteUrl' config value. No need to duplicate work!
This commit is contained in:
parent
bd51dd09db
commit
759f6ed3ba
3 changed files with 3 additions and 12 deletions
|
@ -38,14 +38,12 @@ class UpdateCheckService {
|
||||||
* @param {string[]} [options.config.notificationGroups] - example values ["migration", "something"]
|
* @param {string[]} [options.config.notificationGroups] - example values ["migration", "something"]
|
||||||
* @param {string} options.config.siteUrl - Ghost instance URL
|
* @param {string} options.config.siteUrl - Ghost instance URL
|
||||||
* @param {boolean} [options.config.forceUpdate]
|
* @param {boolean} [options.config.forceUpdate]
|
||||||
* @param {Function} urlFor - function creating a URL for a certain context
|
|
||||||
*/
|
*/
|
||||||
constructor({api, config, i18n, logging, urlFor, request, ghostVersion, ghostMailer}) {
|
constructor({api, config, i18n, logging, request, ghostVersion, ghostMailer}) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.i18n = i18n;
|
this.i18n = i18n;
|
||||||
this.logging = logging;
|
this.logging = logging;
|
||||||
this.urlFor = urlFor;
|
|
||||||
this.request = request;
|
this.request = request;
|
||||||
this.ghostVersion = ghostVersion;
|
this.ghostVersion = ghostVersion;
|
||||||
this.ghostMailer = ghostMailer;
|
this.ghostMailer = ghostMailer;
|
||||||
|
@ -106,7 +104,7 @@ class UpdateCheckService {
|
||||||
const users = await this.api.users.browse(internal);
|
const users = await this.api.users.browse(internal);
|
||||||
const npm = await Promise.promisify(exec)('npm -v');
|
const npm = await Promise.promisify(exec)('npm -v');
|
||||||
|
|
||||||
const blogUrl = this.urlFor('home', true);
|
const blogUrl = this.config.siteUrl;
|
||||||
const parsedBlogUrl = url.parse(blogUrl);
|
const parsedBlogUrl = url.parse(blogUrl);
|
||||||
const blogId = parsedBlogUrl.hostname + parsedBlogUrl.pathname.replace(/\//, '') + hash.value;
|
const blogId = parsedBlogUrl.hostname + parsedBlogUrl.pathname.replace(/\//, '') + hash.value;
|
||||||
|
|
||||||
|
|
|
@ -43,12 +43,11 @@ module.exports = () => {
|
||||||
checkEndpoint: config.get('updateCheck:url'),
|
checkEndpoint: config.get('updateCheck:url'),
|
||||||
isPrivacyDisabled: config.isPrivacyDisabled('useUpdateCheck'),
|
isPrivacyDisabled: config.isPrivacyDisabled('useUpdateCheck'),
|
||||||
notificationGroups: this.config.get('notificationGroups'),
|
notificationGroups: this.config.get('notificationGroups'),
|
||||||
siteUrl: config.get('url'),
|
siteUrl: urlUtils.urlFor('home', true),
|
||||||
forceUpdate: config.get('updateCheck:forceUpdate')
|
forceUpdate: config.get('updateCheck:forceUpdate')
|
||||||
},
|
},
|
||||||
i18n,
|
i18n,
|
||||||
logging,
|
logging,
|
||||||
urlFor: urlUtils.urlFor,
|
|
||||||
request,
|
request,
|
||||||
ghostVersion,
|
ghostVersion,
|
||||||
ghostMailer
|
ghostMailer
|
||||||
|
|
|
@ -13,7 +13,6 @@ describe('Update Check', function () {
|
||||||
let i18nStub;
|
let i18nStub;
|
||||||
let loggingStub;
|
let loggingStub;
|
||||||
let requestStub;
|
let requestStub;
|
||||||
let urlForStub;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
settingsStub = sinon.stub().resolves({
|
settingsStub = sinon.stub().resolves({
|
||||||
|
@ -67,7 +66,6 @@ describe('Update Check', function () {
|
||||||
},
|
},
|
||||||
i18n: i18nStub,
|
i18n: i18nStub,
|
||||||
logging: loggingStub,
|
logging: loggingStub,
|
||||||
urlFor: urlForStub,
|
|
||||||
request: requestStub,
|
request: requestStub,
|
||||||
ghostVersion,
|
ghostVersion,
|
||||||
ghostMailer: {
|
ghostMailer: {
|
||||||
|
@ -131,7 +129,6 @@ describe('Update Check', function () {
|
||||||
},
|
},
|
||||||
i18n: i18nStub,
|
i18n: i18nStub,
|
||||||
logging: loggingStub,
|
logging: loggingStub,
|
||||||
urlFor: urlForStub,
|
|
||||||
request: requestStub,
|
request: requestStub,
|
||||||
ghostVersion,
|
ghostVersion,
|
||||||
ghostMailer: {
|
ghostMailer: {
|
||||||
|
@ -181,7 +178,6 @@ describe('Update Check', function () {
|
||||||
},
|
},
|
||||||
i18n: i18nStub,
|
i18n: i18nStub,
|
||||||
logging: loggingStub,
|
logging: loggingStub,
|
||||||
urlFor: urlForStub,
|
|
||||||
request: requestStub,
|
request: requestStub,
|
||||||
ghostVersion,
|
ghostVersion,
|
||||||
ghostMailer: {
|
ghostMailer: {
|
||||||
|
@ -252,7 +248,6 @@ describe('Update Check', function () {
|
||||||
config: {},
|
config: {},
|
||||||
i18n: i18nStub,
|
i18n: i18nStub,
|
||||||
logging: loggingStub,
|
logging: loggingStub,
|
||||||
urlFor: urlForStub,
|
|
||||||
request: sinon.stub().resolves({
|
request: sinon.stub().resolves({
|
||||||
body: {
|
body: {
|
||||||
notifications: [notification]
|
notifications: [notification]
|
||||||
|
@ -323,7 +318,6 @@ describe('Update Check', function () {
|
||||||
},
|
},
|
||||||
i18n: i18nStub,
|
i18n: i18nStub,
|
||||||
logging: loggingStub,
|
logging: loggingStub,
|
||||||
urlFor: urlForStub,
|
|
||||||
request: sinon.stub().resolves({
|
request: sinon.stub().resolves({
|
||||||
body: [notification]
|
body: [notification]
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in a new issue