diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/plugins/register-helpers-store.ts | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/server/lib/plugins/register-helpers-store.ts b/server/lib/plugins/register-helpers-store.ts index c76c0161a..5ca52b151 100644 --- a/server/lib/plugins/register-helpers-store.ts +++ b/server/lib/plugins/register-helpers-store.ts | |||
@@ -2,7 +2,13 @@ import { PluginSettingsManager } from '@shared/models/plugins/plugin-settings-ma | |||
2 | import { PluginModel } from '@server/models/server/plugin' | 2 | import { PluginModel } from '@server/models/server/plugin' |
3 | import { PluginStorageManager } from '@shared/models/plugins/plugin-storage-manager.model' | 3 | import { PluginStorageManager } from '@shared/models/plugins/plugin-storage-manager.model' |
4 | import { PluginVideoLanguageManager } from '@shared/models/plugins/plugin-video-language-manager.model' | 4 | import { PluginVideoLanguageManager } from '@shared/models/plugins/plugin-video-language-manager.model' |
5 | import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES } from '@server/initializers/constants' | 5 | import { |
6 | VIDEO_CATEGORIES, | ||
7 | VIDEO_LANGUAGES, | ||
8 | VIDEO_LICENCES, | ||
9 | VIDEO_PLAYLIST_PRIVACIES, | ||
10 | VIDEO_PRIVACIES | ||
11 | } from '@server/initializers/constants' | ||
6 | import { PluginVideoLicenceManager } from '@shared/models/plugins/plugin-video-licence-manager.model' | 12 | import { PluginVideoLicenceManager } from '@shared/models/plugins/plugin-video-licence-manager.model' |
7 | import { PluginVideoCategoryManager } from '@shared/models/plugins/plugin-video-category-manager.model' | 13 | import { PluginVideoCategoryManager } from '@shared/models/plugins/plugin-video-category-manager.model' |
8 | import { RegisterServerOptions } from '@server/typings/plugins' | 14 | import { RegisterServerOptions } from '@server/typings/plugins' |
@@ -12,8 +18,10 @@ import { RegisterServerHookOptions } from '@shared/models/plugins/register-serve | |||
12 | import { serverHookObject } from '@shared/models/plugins/server-hook.model' | 18 | import { serverHookObject } from '@shared/models/plugins/server-hook.model' |
13 | import { RegisterServerSettingOptions } from '@shared/models/plugins/register-server-setting.model' | 19 | import { RegisterServerSettingOptions } from '@shared/models/plugins/register-server-setting.model' |
14 | import * as express from 'express' | 20 | import * as express from 'express' |
21 | import { PluginVideoPrivacyManager } from '@shared/models/plugins/plugin-video-privacy-manager.model' | ||
22 | import { PluginPlaylistPrivacyManager } from '@shared/models/plugins/plugin-playlist-privacy-manager.model' | ||
15 | 23 | ||
16 | type AlterableVideoConstant = 'language' | 'licence' | 'category' | 24 | type AlterableVideoConstant = 'language' | 'licence' | 'category' | 'privacy' | 'playlistPrivacy' |
17 | type VideoConstant = { [key in number | string]: string } | 25 | type VideoConstant = { [key in number | string]: string } |
18 | 26 | ||
19 | type UpdatedVideoConstant = { | 27 | type UpdatedVideoConstant = { |
@@ -25,6 +33,8 @@ type UpdatedVideoConstant = { | |||
25 | 33 | ||
26 | export class RegisterHelpersStore { | 34 | export class RegisterHelpersStore { |
27 | private readonly updatedVideoConstants: UpdatedVideoConstant = { | 35 | private readonly updatedVideoConstants: UpdatedVideoConstant = { |
36 | playlistPrivacy: { added: [], deleted: [] }, | ||
37 | privacy: { added: [], deleted: [] }, | ||
28 | language: { added: [], deleted: [] }, | 38 | language: { added: [], deleted: [] }, |
29 | licence: { added: [], deleted: [] }, | 39 | licence: { added: [], deleted: [] }, |
30 | category: { added: [], deleted: [] } | 40 | category: { added: [], deleted: [] } |
@@ -56,6 +66,9 @@ export class RegisterHelpersStore { | |||
56 | const videoLicenceManager = this.buildVideoLicenceManager() | 66 | const videoLicenceManager = this.buildVideoLicenceManager() |
57 | const videoCategoryManager = this.buildVideoCategoryManager() | 67 | const videoCategoryManager = this.buildVideoCategoryManager() |
58 | 68 | ||
69 | const videoPrivacyManager = this.buildVideoPrivacyManager() | ||
70 | const playlistPrivacyManager = this.buildPlaylistPrivacyManager() | ||
71 | |||
59 | const peertubeHelpers = buildPluginHelpers(this.npmName) | 72 | const peertubeHelpers = buildPluginHelpers(this.npmName) |
60 | 73 | ||
61 | return { | 74 | return { |
@@ -71,6 +84,9 @@ export class RegisterHelpersStore { | |||
71 | videoCategoryManager, | 84 | videoCategoryManager, |
72 | videoLicenceManager, | 85 | videoLicenceManager, |
73 | 86 | ||
87 | videoPrivacyManager, | ||
88 | playlistPrivacyManager, | ||
89 | |||
74 | peertubeHelpers | 90 | peertubeHelpers |
75 | } | 91 | } |
76 | } | 92 | } |
@@ -79,9 +95,11 @@ export class RegisterHelpersStore { | |||
79 | const hash = { | 95 | const hash = { |
80 | language: VIDEO_LANGUAGES, | 96 | language: VIDEO_LANGUAGES, |
81 | licence: VIDEO_LICENCES, | 97 | licence: VIDEO_LICENCES, |
82 | category: VIDEO_CATEGORIES | 98 | category: VIDEO_CATEGORIES, |
99 | privacy: VIDEO_PRIVACIES, | ||
100 | playlistPrivacy: VIDEO_PLAYLIST_PRIVACIES | ||
83 | } | 101 | } |
84 | const types: AlterableVideoConstant[] = [ 'language', 'licence', 'category' ] | 102 | const types: AlterableVideoConstant[] = [ 'language', 'licence', 'category', 'privacy', 'playlistPrivacy' ] |
85 | 103 | ||
86 | for (const type of types) { | 104 | for (const type of types) { |
87 | const updatedConstants = this.updatedVideoConstants[type][npmName] | 105 | const updatedConstants = this.updatedVideoConstants[type][npmName] |
@@ -168,6 +186,22 @@ export class RegisterHelpersStore { | |||
168 | } | 186 | } |
169 | } | 187 | } |
170 | 188 | ||
189 | private buildVideoPrivacyManager (): PluginVideoPrivacyManager { | ||
190 | return { | ||
191 | deletePrivacy: (key: number) => { | ||
192 | return this.deleteConstant({ npmName: this.npmName, type: 'privacy', obj: VIDEO_PRIVACIES, key }) | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | |||
197 | private buildPlaylistPrivacyManager (): PluginPlaylistPrivacyManager { | ||
198 | return { | ||
199 | deletePlaylistPrivacy: (key: number) => { | ||
200 | return this.deleteConstant({ npmName: this.npmName, type: 'playlistPrivacy', obj: VIDEO_PLAYLIST_PRIVACIES, key }) | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | |||
171 | private buildVideoLicenceManager (): PluginVideoLicenceManager { | 205 | private buildVideoLicenceManager (): PluginVideoLicenceManager { |
172 | return { | 206 | return { |
173 | addLicence: (key: number, label: string) => { | 207 | addLicence: (key: number, label: string) => { |