aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/models/server/plugin.ts12
-rw-r--r--server/tests/fixtures/peertube-plugin-test-six/main.js5
-rw-r--r--server/tests/plugins/plugin-storage.ts6
3 files changed, 14 insertions, 9 deletions
diff --git a/server/models/server/plugin.ts b/server/models/server/plugin.ts
index a8de64dd4..c79178782 100644
--- a/server/models/server/plugin.ts
+++ b/server/models/server/plugin.ts
@@ -197,15 +197,11 @@ export class PluginModel extends Model<Partial<AttributesOnly<PluginModel>>> {
197 if (!c) return undefined 197 if (!c) return undefined
198 const value = c.value 198 const value = c.value
199 199
200 if (typeof value === 'string' && value.startsWith('{')) { 200 try {
201 try { 201 return JSON.parse(value)
202 return JSON.parse(value) 202 } catch {
203 } catch { 203 return value
204 return value
205 }
206 } 204 }
207
208 return c.value
209 }) 205 })
210 } 206 }
211 207
diff --git a/server/tests/fixtures/peertube-plugin-test-six/main.js b/server/tests/fixtures/peertube-plugin-test-six/main.js
index 858bdb2df..4a9d56ea7 100644
--- a/server/tests/fixtures/peertube-plugin-test-six/main.js
+++ b/server/tests/fixtures/peertube-plugin-test-six/main.js
@@ -11,9 +11,14 @@ async function register ({
11 { 11 {
12 await storageManager.storeData('superkey', { value: 'toto' }) 12 await storageManager.storeData('superkey', { value: 'toto' })
13 await storageManager.storeData('anotherkey', { value: 'toto2' }) 13 await storageManager.storeData('anotherkey', { value: 'toto2' })
14 await storageManager.storeData('storedArrayKey', ['toto', 'toto2'])
14 15
15 const result = await storageManager.getData('superkey') 16 const result = await storageManager.getData('superkey')
16 logger.info('superkey stored value is %s', result.value) 17 logger.info('superkey stored value is %s', result.value)
18
19 const storedArrayValue = await storageManager.getData('storedArrayKey')
20 logger.info('storedArrayKey value type is %s', typeof storedArrayValue)
21 logger.info('storedArrayKey stored value is %s', storedArrayValue.join(', '))
17 } 22 }
18 23
19 { 24 {
diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts
index e20c36dba..ac519045d 100644
--- a/server/tests/plugins/plugin-storage.ts
+++ b/server/tests/plugins/plugin-storage.ts
@@ -27,10 +27,14 @@ describe('Test plugin storage', function () {
27 }) 27 })
28 28
29 describe('DB storage', function () { 29 describe('DB storage', function () {
30
31 it('Should correctly store a subkey', async function () { 30 it('Should correctly store a subkey', async function () {
32 await server.servers.waitUntilLog('superkey stored value is toto') 31 await server.servers.waitUntilLog('superkey stored value is toto')
33 }) 32 })
33
34 it('Should correctly retrieve an array as array from the storage.', async function () {
35 await server.servers.waitUntilLog('storedArrayKey value type is array')
36 await server.servers.waitUntilLog('storedArrayKey stored value is toto, toto2')
37 })
34 }) 38 })
35 39
36 describe('Disk storage', function () { 40 describe('Disk storage', function () {