aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-04 09:44:00 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-04 16:21:39 +0200
commit97b65ce58aaacbbfec2291f18fb95a9da9eb5263 (patch)
tree98779224aabe3f5c5eefbcde46b0a50ae48e761c /server/models
parent15b4bcdf04db86c655ae16d4832ae2a8f0e55829 (diff)
downloadPeerTube-97b65ce58aaacbbfec2291f18fb95a9da9eb5263.tar.gz
PeerTube-97b65ce58aaacbbfec2291f18fb95a9da9eb5263.tar.zst
PeerTube-97b65ce58aaacbbfec2291f18fb95a9da9eb5263.zip
Fix plugin storeData
Diffstat (limited to 'server/models')
-rw-r--r--server/models/server/plugin.ts19
1 files changed, 9 insertions, 10 deletions
diff --git a/server/models/server/plugin.ts b/server/models/server/plugin.ts
index c72846343..53b6227d7 100644
--- a/server/models/server/plugin.ts
+++ b/server/models/server/plugin.ts
@@ -1,5 +1,5 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { FindAndCountOptions, json } from 'sequelize' 2import { FindAndCountOptions, json, QueryTypes } from 'sequelize'
3import { AllowNull, Column, CreatedAt, DataType, DefaultScope, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' 3import { AllowNull, Column, CreatedAt, DataType, DefaultScope, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
4import { MPlugin, MPluginFormattable } from '@server/typings/models' 4import { MPlugin, MPluginFormattable } from '@server/typings/models'
5import { PeerTubePlugin } from '../../../shared/models/plugins/peertube-plugin.model' 5import { PeerTubePlugin } from '../../../shared/models/plugins/peertube-plugin.model'
@@ -212,18 +212,17 @@ export class PluginModel extends Model<PluginModel> {
212 } 212 }
213 213
214 static storeData (pluginName: string, pluginType: PluginType, key: string, data: any) { 214 static storeData (pluginName: string, pluginType: PluginType, key: string, data: any) {
215 const query = { 215 const query = 'UPDATE "plugin" SET "storage" = jsonb_set(coalesce("storage", \'{}\'), :key, :data::jsonb) ' +
216 where: { 216 'WHERE "name" = :pluginName AND "type" = :pluginType'
217 name: pluginName,
218 type: pluginType
219 }
220 }
221 217
222 const toSave = { 218 const jsonPath = '{' + key + '}'
223 [`storage.${key}`]: data 219
220 const options = {
221 replacements: { pluginName, pluginType, key: jsonPath, data: JSON.stringify(data) },
222 type: QueryTypes.UPDATE
224 } 223 }
225 224
226 return PluginModel.update(toSave, query) 225 return PluginModel.sequelize.query(query, options)
227 .then(() => undefined) 226 .then(() => undefined)
228 } 227 }
229 228