aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-20 16:02:15 +0200
committerChocobozzz <me@florianbigard.com>2021-04-20 16:02:15 +0200
commit24a792404cac0dffff91853af33310fbb7a30297 (patch)
tree997f771146fe57527ca50a2d6e18febbc9baf124 /server
parent51b66ea7cb39f075f4deb8ea92ba70f3be289769 (diff)
downloadPeerTube-24a792404cac0dffff91853af33310fbb7a30297.tar.gz
PeerTube-24a792404cac0dffff91853af33310fbb7a30297.tar.zst
PeerTube-24a792404cac0dffff91853af33310fbb7a30297.zip
Support async onSettingsChange
Diffstat (limited to 'server')
-rw-r--r--server/lib/plugins/plugin-manager.ts4
-rw-r--r--server/lib/plugins/register-helpers.ts4
2 files changed, 4 insertions, 4 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index 03ea48416..f3766ffa8 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -189,7 +189,7 @@ export class PluginManager implements ServerHook {
189 return undefined 189 return undefined
190 } 190 }
191 191
192 onSettingsChanged (name: string, settings: any) { 192 async onSettingsChanged (name: string, settings: any) {
193 const registered = this.getRegisteredPluginByShortName(name) 193 const registered = this.getRegisteredPluginByShortName(name)
194 if (!registered) { 194 if (!registered) {
195 logger.error('Cannot find plugin %s to call on settings changed.', name) 195 logger.error('Cannot find plugin %s to call on settings changed.', name)
@@ -197,7 +197,7 @@ export class PluginManager implements ServerHook {
197 197
198 for (const cb of registered.registerHelpers.getOnSettingsChangedCallbacks()) { 198 for (const cb of registered.registerHelpers.getOnSettingsChangedCallbacks()) {
199 try { 199 try {
200 cb(settings) 200 await cb(settings)
201 } catch (err) { 201 } catch (err) {
202 logger.error('Cannot run on settings changed callback for %s.', registered.npmName, { err }) 202 logger.error('Cannot run on settings changed callback for %s.', registered.npmName, { err })
203 } 203 }
diff --git a/server/lib/plugins/register-helpers.ts b/server/lib/plugins/register-helpers.ts
index c018e54a8..aa69ca2a2 100644
--- a/server/lib/plugins/register-helpers.ts
+++ b/server/lib/plugins/register-helpers.ts
@@ -73,7 +73,7 @@ export class RegisterHelpers {
73 private idAndPassAuths: RegisterServerAuthPassOptions[] = [] 73 private idAndPassAuths: RegisterServerAuthPassOptions[] = []
74 private externalAuths: RegisterServerAuthExternalOptions[] = [] 74 private externalAuths: RegisterServerAuthExternalOptions[] = []
75 75
76 private readonly onSettingsChangeCallbacks: ((settings: any) => void)[] = [] 76 private readonly onSettingsChangeCallbacks: ((settings: any) => Promise<any>)[] = []
77 77
78 private readonly router: express.Router 78 private readonly router: express.Router
79 79
@@ -277,7 +277,7 @@ export class RegisterHelpers {
277 277
278 setSetting: (name: string, value: string) => PluginModel.setSetting(this.plugin.name, this.plugin.type, name, value), 278 setSetting: (name: string, value: string) => PluginModel.setSetting(this.plugin.name, this.plugin.type, name, value),
279 279
280 onSettingsChange: (cb: (settings: any) => void) => this.onSettingsChangeCallbacks.push(cb) 280 onSettingsChange: (cb: (settings: any) => Promise<any>) => this.onSettingsChangeCallbacks.push(cb)
281 } 281 }
282 } 282 }
283 283