aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/plugins/register-helpers.ts28
1 files changed, 19 insertions, 9 deletions
diff --git a/server/lib/plugins/register-helpers.ts b/server/lib/plugins/register-helpers.ts
index f5b573370..09275f9ba 100644
--- a/server/lib/plugins/register-helpers.ts
+++ b/server/lib/plugins/register-helpers.ts
@@ -37,18 +37,20 @@ type VideoConstant = { [key in number | string]: string }
37 37
38type UpdatedVideoConstant = { 38type UpdatedVideoConstant = {
39 [name in AlterableVideoConstant]: { 39 [name in AlterableVideoConstant]: {
40 added: { key: number | string, label: string }[] 40 [ npmName: string]: {
41 deleted: { key: number | string, label: string }[] 41 added: { key: number | string, label: string }[]
42 deleted: { key: number | string, label: string }[]
43 }
42 } 44 }
43} 45}
44 46
45export class RegisterHelpers { 47export class RegisterHelpers {
46 private readonly updatedVideoConstants: UpdatedVideoConstant = { 48 private readonly updatedVideoConstants: UpdatedVideoConstant = {
47 playlistPrivacy: { added: [], deleted: [] }, 49 playlistPrivacy: { },
48 privacy: { added: [], deleted: [] }, 50 privacy: { },
49 language: { added: [], deleted: [] }, 51 language: { },
50 licence: { added: [], deleted: [] }, 52 licence: { },
51 category: { added: [], deleted: [] } 53 category: { }
52 } 54 }
53 55
54 private readonly transcodingProfiles: { 56 private readonly transcodingProfiles: {
@@ -377,7 +379,7 @@ export class RegisterHelpers {
377 const { npmName, type, obj, key } = parameters 379 const { npmName, type, obj, key } = parameters
378 380
379 if (!obj[key]) { 381 if (!obj[key]) {
380 logger.warn('Cannot delete %s %s by plugin %s: key does not exist.', type, npmName, key) 382 logger.warn('Cannot delete %s by plugin %s: key %s does not exist.', type, npmName, key)
381 return false 383 return false
382 } 384 }
383 385
@@ -388,7 +390,15 @@ export class RegisterHelpers {
388 } 390 }
389 } 391 }
390 392
391 this.updatedVideoConstants[type][npmName].deleted.push({ key, label: obj[key] }) 393 const updatedConstants = this.updatedVideoConstants[type][npmName]
394
395 const alreadyAdded = updatedConstants.added.find(a => a.key === key)
396 if (alreadyAdded) {
397 updatedConstants.added.filter(a => a.key !== key)
398 } else if (obj[key]) {
399 updatedConstants.deleted.push({ key, label: obj[key] })
400 }
401
392 delete obj[key] 402 delete obj[key]
393 403
394 return true 404 return true