diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-26 09:35:43 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-07-26 15:18:29 +0200 |
commit | ba211e7386bb2f25e37a4c5bcdfeb4237e1cd315 (patch) | |
tree | 398bb14a92c7df3765a0a64bac9f4672c5588488 /shared | |
parent | 23bdacf8ec24ce47a15529830e116911d7478598 (diff) | |
download | PeerTube-ba211e7386bb2f25e37a4c5bcdfeb4237e1cd315.tar.gz PeerTube-ba211e7386bb2f25e37a4c5bcdfeb4237e1cd315.tar.zst PeerTube-ba211e7386bb2f25e37a4c5bcdfeb4237e1cd315.zip |
Add public settings endpoint
Diffstat (limited to 'shared')
-rw-r--r-- | shared/extra-utils/server/plugins.ts | 18 | ||||
-rw-r--r-- | shared/models/plugins/public-server.setting.ts | 3 | ||||
-rw-r--r-- | shared/models/plugins/register-server-setting.model.ts | 8 |
3 files changed, 27 insertions, 2 deletions
diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts index 2302208a8..65d37d69f 100644 --- a/shared/extra-utils/server/plugins.ts +++ b/shared/extra-utils/server/plugins.ts | |||
@@ -119,6 +119,21 @@ function getPluginRegisteredSettings (parameters: { | |||
119 | }) | 119 | }) |
120 | } | 120 | } |
121 | 121 | ||
122 | function getPublicSettings (parameters: { | ||
123 | url: string, | ||
124 | npmName: string, | ||
125 | expectedStatus?: number | ||
126 | }) { | ||
127 | const { url, npmName, expectedStatus = 200 } = parameters | ||
128 | const path = '/api/v1/plugins/' + npmName + '/public-settings' | ||
129 | |||
130 | return makeGetRequest({ | ||
131 | url, | ||
132 | path, | ||
133 | statusCodeExpected: expectedStatus | ||
134 | }) | ||
135 | } | ||
136 | |||
122 | function installPlugin (parameters: { | 137 | function installPlugin (parameters: { |
123 | url: string, | 138 | url: string, |
124 | accessToken: string, | 139 | accessToken: string, |
@@ -218,5 +233,6 @@ export { | |||
218 | getPackageJSONPath, | 233 | getPackageJSONPath, |
219 | updatePluginPackageJSON, | 234 | updatePluginPackageJSON, |
220 | getPluginPackageJSON, | 235 | getPluginPackageJSON, |
221 | getPluginTestPath | 236 | getPluginTestPath, |
237 | getPublicSettings | ||
222 | } | 238 | } |
diff --git a/shared/models/plugins/public-server.setting.ts b/shared/models/plugins/public-server.setting.ts new file mode 100644 index 000000000..9802c4d7d --- /dev/null +++ b/shared/models/plugins/public-server.setting.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface PublicServerSetting { | ||
2 | publicSettings: { [ name: string ]: string } | ||
3 | } | ||
diff --git a/shared/models/plugins/register-server-setting.model.ts b/shared/models/plugins/register-server-setting.model.ts index 5dea93c39..78c5abd1b 100644 --- a/shared/models/plugins/register-server-setting.model.ts +++ b/shared/models/plugins/register-server-setting.model.ts | |||
@@ -2,9 +2,15 @@ export interface RegisterServerSettingOptions { | |||
2 | name: string | 2 | name: string |
3 | label: string | 3 | label: string |
4 | type: 'input' | 4 | type: 'input' |
5 | |||
6 | // If the setting is not private, anyone can view its value | ||
7 | // Mainly used by the PeerTube client to get admin config | ||
8 | private: boolean | ||
9 | |||
10 | // Default setting value | ||
5 | default?: string | 11 | default?: string |
6 | } | 12 | } |
7 | 13 | ||
8 | export interface RegisteredServerSettings { | 14 | export interface RegisteredServerSettings { |
9 | settings: RegisterServerSettingOptions[] | 15 | registeredSettings: RegisterServerSettingOptions[] |
10 | } | 16 | } |