diff options
Diffstat (limited to 'server/tests/fixtures/peertube-plugin-test/main.js')
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test/main.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js new file mode 100644 index 000000000..fae0ef948 --- /dev/null +++ b/server/tests/fixtures/peertube-plugin-test/main.js | |||
@@ -0,0 +1,39 @@ | |||
1 | async function register ({ registerHook, registerSetting, settingsManager, storageManager }) { | ||
2 | const defaultAdmin = 'PeerTube admin' | ||
3 | |||
4 | registerHook({ | ||
5 | target: 'action:application.listening', | ||
6 | handler: () => displayHelloWorld(settingsManager, defaultAdmin) | ||
7 | }) | ||
8 | |||
9 | registerSetting({ | ||
10 | name: 'admin-name', | ||
11 | label: 'Admin name', | ||
12 | type: 'input', | ||
13 | default: defaultAdmin | ||
14 | }) | ||
15 | |||
16 | const value = await storageManager.getData('toto') | ||
17 | console.log(value) | ||
18 | console.log(value.coucou) | ||
19 | |||
20 | await storageManager.storeData('toto', { coucou: 'hello' + new Date() }) | ||
21 | } | ||
22 | |||
23 | async function unregister () { | ||
24 | return | ||
25 | } | ||
26 | |||
27 | module.exports = { | ||
28 | register, | ||
29 | unregister | ||
30 | } | ||
31 | |||
32 | // ############################################################################ | ||
33 | |||
34 | async function displayHelloWorld (settingsManager, defaultAdmin) { | ||
35 | let value = await settingsManager.getSetting('admin-name') | ||
36 | if (!value) value = defaultAdmin | ||
37 | |||
38 | console.log('hello world ' + value) | ||
39 | } | ||