// settings endpoints RocketChat.API.v1.addRoute('settings/:_id', { authRequired: true }, { get() { if (!RocketChat.authz.hasPermission(this.userId, 'view-privileged-setting')) { return RocketChat.API.v1.unauthorized(); } return RocketChat.API.v1.success(_.pick(RocketChat.models.Settings.findOneNotHiddenById(this.urlParams._id), '_id', 'value')); }, post() { if (!RocketChat.authz.hasPermission(this.userId, 'edit-privileged-setting')) { return RocketChat.API.v1.unauthorized(); } try { check(this.bodyParams, { value: Match.Any }); if (RocketChat.models.Settings.updateValueNotHiddenById(this.urlParams._id, this.bodyParams.value)) { return RocketChat.API.v1.success(); } return RocketChat.API.v1.failure(); } catch (e) { return RocketChat.API.v1.failure(e.message); } } });