ghost 4.20.0 → 4.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,9 +55,8 @@ module.exports = {
55
55
  this.browse(...arguments);
56
56
  },
57
57
 
58
- edit(models, apiConfig, frame) {
59
- const settingsKeyedJSON = _.keyBy(_.invokeMap(models, 'toJSON'), 'key');
60
- this.browse(settingsKeyedJSON, apiConfig, frame);
58
+ edit() {
59
+ this.browse(...arguments);
61
60
  },
62
61
 
63
62
  download(bytes, apiConfig, frame) {
@@ -55,9 +55,8 @@ module.exports = {
55
55
  this.browse(...arguments);
56
56
  },
57
57
 
58
- edit(models, apiConfig, frame) {
59
- const settingsKeyedJSON = _.keyBy(_.invokeMap(models, 'toJSON'), 'key');
60
- this.browse(settingsKeyedJSON, apiConfig, frame);
58
+ edit() {
59
+ this.browse(...arguments);
61
60
  },
62
61
 
63
62
  download(bytes, apiConfig, frame) {
@@ -4,6 +4,7 @@
4
4
  */
5
5
  const events = require('../../lib/common/events');
6
6
  const models = require('../../models');
7
+ const labs = require('../../../shared/labs');
7
8
  const SettingsCache = require('../../../shared/settings-cache');
8
9
  const SettingsBREADService = require('./settings-bread-service');
9
10
  const {obfuscatedSetting, isSecretSetting, hideValueIfSecret} = require('./settings-utils');
@@ -14,7 +15,8 @@ const {obfuscatedSetting, isSecretSetting, hideValueIfSecret} = require('./setti
14
15
  const getSettingsBREADServiceInstance = () => {
15
16
  return new SettingsBREADService({
16
17
  SettingsModel: models.Settings,
17
- settingsCache: SettingsCache
18
+ settingsCache: SettingsCache,
19
+ labsService: labs
18
20
  });
19
21
  };
20
22
 
@@ -14,10 +14,12 @@ class SettingsBREADService {
14
14
  * @param {Object} options
15
15
  * @param {Object} options.SettingsModel
16
16
  * @param {Object} options.settingsCache - SettingsCache instance
17
+ * @param {Object} options.labsService - labs service instance
17
18
  */
18
- constructor({SettingsModel, settingsCache}) {
19
+ constructor({SettingsModel, settingsCache, labsService}) {
19
20
  this.SettingsModel = SettingsModel;
20
21
  this.settingsCache = settingsCache;
22
+ this.labs = labsService;
21
23
  }
22
24
 
23
25
  /**
@@ -28,24 +30,7 @@ class SettingsBREADService {
28
30
  browse(context) {
29
31
  let settings = this.settingsCache.getAll();
30
32
 
31
- // CASE: no context passed (functional call)
32
- if (!context) {
33
- return Promise.resolve(settings.filter((setting) => {
34
- return setting.group === 'site';
35
- }));
36
- }
37
-
38
- if (!context.internal) {
39
- // CASE: omit core settings unless internal request
40
- settings = _.filter(settings, (setting) => {
41
- const isCore = setting.group === 'core';
42
- return !isCore;
43
- });
44
- // CASE: omit secret settings unless internal request
45
- settings = settings.map(hideValueIfSecret);
46
- }
47
-
48
- return settings;
33
+ return this._formatBrowse(settings, context);
49
34
  }
50
35
 
51
36
  /**
@@ -86,6 +71,12 @@ class SettingsBREADService {
86
71
  }));
87
72
  }
88
73
 
74
+ // NOTE: Labs flags can exist outside of the DB when they are forced on/off
75
+ // so we grab them from the labs service instead as that's source-of-truth
76
+ if (setting.key === 'labs') {
77
+ setting.value = JSON.stringify(this.labs.getAll());
78
+ }
79
+
89
80
  setting = hideValueIfSecret(setting);
90
81
 
91
82
  return {
@@ -161,7 +152,9 @@ class SettingsBREADService {
161
152
  });
162
153
  }
163
154
 
164
- return this.SettingsModel.edit(filteredSettings, options);
155
+ return this.SettingsModel.edit(filteredSettings, options).then((result) => {
156
+ return this._formatBrowse(_.keyBy(_.invokeMap(result, 'toJSON'), 'key'), options.context);
157
+ });
165
158
  }
166
159
 
167
160
  /**
@@ -183,6 +176,35 @@ class SettingsBREADService {
183
176
  }
184
177
  }
185
178
  }
179
+
180
+ _formatBrowse(inputSettings, context) {
181
+ let settings = _.values(inputSettings);
182
+ // CASE: no context passed (functional call)
183
+ if (!context) {
184
+ return Promise.resolve(settings.filter((setting) => {
185
+ return setting.group === 'site';
186
+ }));
187
+ }
188
+
189
+ if (!context.internal) {
190
+ // CASE: omit core settings unless internal request
191
+ settings = _.filter(settings, (setting) => {
192
+ const isCore = setting.group === 'core';
193
+ return !isCore;
194
+ });
195
+ // CASE: omit secret settings unless internal request
196
+ settings = settings.map(hideValueIfSecret);
197
+ }
198
+
199
+ // NOTE: Labs flags can exist outside of the DB when they are forced on/off
200
+ // so we grab them from the labs service instead as that's source-of-truth
201
+ const labsSetting = settings.find(setting => setting.key === 'labs');
202
+ if (labsSetting) {
203
+ labsSetting.value = JSON.stringify(this.labs.getAll());
204
+ }
205
+
206
+ return settings;
207
+ }
186
208
  }
187
209
 
188
210
  module.exports = SettingsBREADService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ghost",
3
- "version": "4.20.0",
3
+ "version": "4.20.1",
4
4
  "description": "The professional publishing platform",
5
5
  "author": "Ghost Foundation",
6
6
  "homepage": "https://ghost.org",
@@ -158,7 +158,7 @@
158
158
  "mysql": "2.18.1",
159
159
  "nconf": "0.11.3",
160
160
  "node-jose": "2.0.0",
161
- "oembed-parser": "1.4.8",
161
+ "oembed-parser": "1.4.9",
162
162
  "passport": "0.5.0",
163
163
  "passport-google-oauth": "2.0.0",
164
164
  "path-match": "1.2.4",
package/yarn.lock CHANGED
@@ -8446,10 +8446,10 @@ object.pick@^1.2.0, object.pick@^1.3.0:
8446
8446
  dependencies:
8447
8447
  isobject "^3.0.1"
8448
8448
 
8449
- oembed-parser@1.4.8:
8450
- version "1.4.8"
8451
- resolved "https://registry.yarnpkg.com/oembed-parser/-/oembed-parser-1.4.8.tgz#a7961756358db0121c9bea1d66df889f9839f08f"
8452
- integrity sha512-9CKgXRcxg2geW/SgMJDHLZ/CTAfvdQNcBmbEvBkYX3CxvE/DFR2f/bW/PCmDWBonJ4bIJnN+dKJ46ZO+VFwNeQ==
8449
+ oembed-parser@1.4.9:
8450
+ version "1.4.9"
8451
+ resolved "https://registry.yarnpkg.com/oembed-parser/-/oembed-parser-1.4.9.tgz#d23127c96185dfa2d998b8567e6c7df164f3d824"
8452
+ integrity sha512-RCOjuv20IMm9XekZB1ZefdYPc+x5qe8IyCeY/xcN71I2z70vQl+L420eI5Mjyy/NQFLv+QPEgj/aYh1vptO83w==
8453
8453
  dependencies:
8454
8454
  cross-fetch "^3.1.4"
8455
8455