aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/plugins/register-helpers-store.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-30 09:28:39 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-04 16:21:39 +0200
commita5896799f169d3313b63165fe6a79d4149fa6df1 (patch)
tree0151902e829dce13bbb22ff0fe6967ce6bee4058 /server/lib/plugins/register-helpers-store.ts
parentdadc90bca257f2d785713a37949c3a1bf6a5243d (diff)
downloadPeerTube-a5896799f169d3313b63165fe6a79d4149fa6df1.tar.gz
PeerTube-a5896799f169d3313b63165fe6a79d4149fa6df1.tar.zst
PeerTube-a5896799f169d3313b63165fe6a79d4149fa6df1.zip
Add plugin settings change watcher
Diffstat (limited to 'server/lib/plugins/register-helpers-store.ts')
-rw-r--r--server/lib/plugins/register-helpers-store.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/server/lib/plugins/register-helpers-store.ts b/server/lib/plugins/register-helpers-store.ts
index 151196bf1..6317ac2cf 100644
--- a/server/lib/plugins/register-helpers-store.ts
+++ b/server/lib/plugins/register-helpers-store.ts
@@ -52,6 +52,8 @@ export class RegisterHelpersStore {
52 private readonly idAndPassAuths: RegisterServerAuthPassOptions[] = [] 52 private readonly idAndPassAuths: RegisterServerAuthPassOptions[] = []
53 private readonly externalAuths: RegisterServerAuthExternalOptions[] = [] 53 private readonly externalAuths: RegisterServerAuthExternalOptions[] = []
54 54
55 private readonly onSettingsChangeCallbacks: ((settings: any) => void)[] = []
56
55 private readonly router: express.Router 57 private readonly router: express.Router
56 58
57 constructor ( 59 constructor (
@@ -149,6 +151,10 @@ export class RegisterHelpersStore {
149 return this.externalAuths 151 return this.externalAuths
150 } 152 }
151 153
154 getOnSettingsChangedCallbacks () {
155 return this.onSettingsChangeCallbacks
156 }
157
152 private buildGetRouter () { 158 private buildGetRouter () {
153 return () => this.router 159 return () => this.router
154 } 160 }
@@ -185,7 +191,7 @@ export class RegisterHelpersStore {
185 const self = this 191 const self = this
186 192
187 return (options: RegisterServerAuthExternalOptions) => { 193 return (options: RegisterServerAuthExternalOptions) => {
188 if (!options.authName || !options.onAuthRequest || typeof options.onAuthRequest !== 'function') { 194 if (!options.authName || typeof options.authDisplayName !== 'function' || typeof options.onAuthRequest !== 'function') {
189 logger.error('Cannot register auth plugin %s: authName of getWeight or login are not valid.', this.npmName) 195 logger.error('Cannot register auth plugin %s: authName of getWeight or login are not valid.', this.npmName)
190 return 196 return
191 } 197 }
@@ -212,7 +218,9 @@ export class RegisterHelpersStore {
212 218
213 getSettings: (names: string[]) => PluginModel.getSettings(this.plugin.name, this.plugin.type, names), 219 getSettings: (names: string[]) => PluginModel.getSettings(this.plugin.name, this.plugin.type, names),
214 220
215 setSetting: (name: string, value: string) => PluginModel.setSetting(this.plugin.name, this.plugin.type, name, value) 221 setSetting: (name: string, value: string) => PluginModel.setSetting(this.plugin.name, this.plugin.type, name, value),
222
223 onSettingsChange: (cb: (settings: any) => void) => this.onSettingsChangeCallbacks.push(cb)
216 } 224 }
217 } 225 }
218 226