aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/plugins')
-rw-r--r--server/lib/plugins/register-helpers-store.ts42
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
2import { PluginModel } from '@server/models/server/plugin' 2import { PluginModel } from '@server/models/server/plugin'
3import { PluginStorageManager } from '@shared/models/plugins/plugin-storage-manager.model' 3import { PluginStorageManager } from '@shared/models/plugins/plugin-storage-manager.model'
4import { PluginVideoLanguageManager } from '@shared/models/plugins/plugin-video-language-manager.model' 4import { PluginVideoLanguageManager } from '@shared/models/plugins/plugin-video-language-manager.model'
5import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES } from '@server/initializers/constants' 5import {
6 VIDEO_CATEGORIES,
7 VIDEO_LANGUAGES,
8 VIDEO_LICENCES,
9 VIDEO_PLAYLIST_PRIVACIES,
10 VIDEO_PRIVACIES
11} from '@server/initializers/constants'
6import { PluginVideoLicenceManager } from '@shared/models/plugins/plugin-video-licence-manager.model' 12import { PluginVideoLicenceManager } from '@shared/models/plugins/plugin-video-licence-manager.model'
7import { PluginVideoCategoryManager } from '@shared/models/plugins/plugin-video-category-manager.model' 13import { PluginVideoCategoryManager } from '@shared/models/plugins/plugin-video-category-manager.model'
8import { RegisterServerOptions } from '@server/typings/plugins' 14import { RegisterServerOptions } from '@server/typings/plugins'
@@ -12,8 +18,10 @@ import { RegisterServerHookOptions } from '@shared/models/plugins/register-serve
12import { serverHookObject } from '@shared/models/plugins/server-hook.model' 18import { serverHookObject } from '@shared/models/plugins/server-hook.model'
13import { RegisterServerSettingOptions } from '@shared/models/plugins/register-server-setting.model' 19import { RegisterServerSettingOptions } from '@shared/models/plugins/register-server-setting.model'
14import * as express from 'express' 20import * as express from 'express'
21import { PluginVideoPrivacyManager } from '@shared/models/plugins/plugin-video-privacy-manager.model'
22import { PluginPlaylistPrivacyManager } from '@shared/models/plugins/plugin-playlist-privacy-manager.model'
15 23
16type AlterableVideoConstant = 'language' | 'licence' | 'category' 24type AlterableVideoConstant = 'language' | 'licence' | 'category' | 'privacy' | 'playlistPrivacy'
17type VideoConstant = { [key in number | string]: string } 25type VideoConstant = { [key in number | string]: string }
18 26
19type UpdatedVideoConstant = { 27type UpdatedVideoConstant = {
@@ -25,6 +33,8 @@ type UpdatedVideoConstant = {
25 33
26export class RegisterHelpersStore { 34export 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) => {