aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-26 09:35:43 +0200
committerChocobozzz <me@florianbigard.com>2019-07-26 15:18:29 +0200
commitba211e7386bb2f25e37a4c5bcdfeb4237e1cd315 (patch)
tree398bb14a92c7df3765a0a64bac9f4672c5588488 /server/models
parent23bdacf8ec24ce47a15529830e116911d7478598 (diff)
downloadPeerTube-ba211e7386bb2f25e37a4c5bcdfeb4237e1cd315.tar.gz
PeerTube-ba211e7386bb2f25e37a4c5bcdfeb4237e1cd315.tar.zst
PeerTube-ba211e7386bb2f25e37a4c5bcdfeb4237e1cd315.zip
Add public settings endpoint
Diffstat (limited to 'server/models')
-rw-r--r--server/models/server/plugin.ts15
1 files changed, 14 insertions, 1 deletions
diff --git a/server/models/server/plugin.ts b/server/models/server/plugin.ts
index f39b97ef0..a15f9a7e2 100644
--- a/server/models/server/plugin.ts
+++ b/server/models/server/plugin.ts
@@ -10,7 +10,7 @@ import {
10import { PluginType } from '../../../shared/models/plugins/plugin.type' 10import { PluginType } from '../../../shared/models/plugins/plugin.type'
11import { PeerTubePlugin } from '../../../shared/models/plugins/peertube-plugin.model' 11import { PeerTubePlugin } from '../../../shared/models/plugins/peertube-plugin.model'
12import { FindAndCountOptions, json } from 'sequelize' 12import { FindAndCountOptions, json } from 'sequelize'
13import { PeerTubePluginIndex } from '../../../shared/models/plugins/peertube-plugin-index.model' 13import { RegisterServerSettingOptions } from '../../../shared/models/plugins/register-server-setting.model'
14 14
15@DefaultScope(() => ({ 15@DefaultScope(() => ({
16 attributes: { 16 attributes: {
@@ -238,6 +238,19 @@ export class PluginModel extends Model<PluginModel> {
238 return 'peertube-plugin-' + name 238 return 'peertube-plugin-' + name
239 } 239 }
240 240
241 getPublicSettings (registeredSettings: RegisterServerSettingOptions[]) {
242 const result: { [ name: string ]: string } = {}
243 const settings = this.settings || {}
244
245 for (const r of registeredSettings) {
246 if (r.private !== false) continue
247
248 result[r.name] = settings[r.name] || r.default || null
249 }
250
251 return result
252 }
253
241 toFormattedJSON (): PeerTubePlugin { 254 toFormattedJSON (): PeerTubePlugin {
242 return { 255 return {
243 name: this.name, 256 name: this.name,