From ba211e7386bb2f25e37a4c5bcdfeb4237e1cd315 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 26 Jul 2019 09:35:43 +0200 Subject: Add public settings endpoint --- server/models/server/plugin.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'server/models') 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 { import { PluginType } from '../../../shared/models/plugins/plugin.type' import { PeerTubePlugin } from '../../../shared/models/plugins/peertube-plugin.model' import { FindAndCountOptions, json } from 'sequelize' -import { PeerTubePluginIndex } from '../../../shared/models/plugins/peertube-plugin-index.model' +import { RegisterServerSettingOptions } from '../../../shared/models/plugins/register-server-setting.model' @DefaultScope(() => ({ attributes: { @@ -238,6 +238,19 @@ export class PluginModel extends Model { return 'peertube-plugin-' + name } + getPublicSettings (registeredSettings: RegisterServerSettingOptions[]) { + const result: { [ name: string ]: string } = {} + const settings = this.settings || {} + + for (const r of registeredSettings) { + if (r.private !== false) continue + + result[r.name] = settings[r.name] || r.default || null + } + + return result + } + toFormattedJSON (): PeerTubePlugin { return { name: this.name, -- cgit v1.2.3