mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
Adjusting based on PR feedback, added public filter to settings object
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const mongoose = require('../mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
const _ = require('lodash');
|
||||
const cache = require('../cache');
|
||||
|
||||
/**
|
||||
@@ -82,6 +83,14 @@ SettingService.update = (settings) => Setting.findOneAndUpdate(selector, {
|
||||
.then(() => settings);
|
||||
});
|
||||
|
||||
/**
|
||||
* Filters the document to ensure that the resulting document is indeed ready
|
||||
* for non authenticated users.
|
||||
* @param {Object} settings the source settings object
|
||||
* @return {Object} the filtered settings object
|
||||
*/
|
||||
SettingService.public = (settings) => _.pick(settings, ['moderation', 'infoBoxEnable', 'infoBoxContent']);
|
||||
|
||||
/**
|
||||
* This is run once when the app starts to ensure settings are populated.
|
||||
* @return {Promise} null initialize the global settings object
|
||||
|
||||
Reference in New Issue
Block a user