]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/types/plugins/register-server-option.model.ts
473990eb6a2a920f4c50b922fd6708efff5071d2
[github/Chocobozzz/PeerTube.git] / server / types / plugins / register-server-option.model.ts
1 import { Response, Router } from 'express'
2 import { Logger } from 'winston'
3 import { ActorModel } from '@server/models/actor/actor'
4 import {
5 PluginPlaylistPrivacyManager,
6 PluginSettingsManager,
7 PluginStorageManager,
8 PluginTranscodingManager,
9 PluginVideoCategoryManager,
10 PluginVideoLanguageManager,
11 PluginVideoLicenceManager,
12 PluginVideoPrivacyManager,
13 RegisterServerHookOptions,
14 RegisterServerSettingOptions,
15 ServerConfig,
16 ThumbnailType,
17 UserRole,
18 VideoBlacklistCreate
19 } from '@shared/models'
20 import { MVideoThumbnail } from '../models'
21 import {
22 RegisterServerAuthExternalOptions,
23 RegisterServerAuthExternalResult,
24 RegisterServerAuthPassOptions
25 } from './register-server-auth.model'
26
27 export type PeerTubeHelpers = {
28 logger: Logger
29
30 database: {
31 query: Function
32 }
33
34 videos: {
35 loadByUrl: (url: string) => Promise<MVideoThumbnail>
36 loadByIdOrUUID: (id: number | string) => Promise<MVideoThumbnail>
37
38 removeVideo: (videoId: number) => Promise<void>
39
40 getFiles: (id: number | string) => Promise<{
41 webtorrent: {
42 videoFiles: {
43 path: string // Could be null if using remote storage
44 url: string
45 resolution: number
46 size: number
47 fps: number
48 }[]
49 }
50
51 hls: {
52 videoFiles: {
53 path: string // Could be null if using remote storage
54 url: string
55 resolution: number
56 size: number
57 fps: number
58 }[]
59 }
60
61 thumbnails: {
62 type: ThumbnailType
63 path: string
64 }[]
65 }>
66 }
67
68 config: {
69 getWebserverUrl: () => string
70
71 getServerConfig: () => Promise<ServerConfig>
72 }
73
74 moderation: {
75 blockServer: (options: { byAccountId: number, hostToBlock: string }) => Promise<void>
76 unblockServer: (options: { byAccountId: number, hostToUnblock: string }) => Promise<void>
77 blockAccount: (options: { byAccountId: number, handleToBlock: string }) => Promise<void>
78 unblockAccount: (options: { byAccountId: number, handleToUnblock: string }) => Promise<void>
79
80 blacklistVideo: (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => Promise<void>
81 unblacklistVideo: (options: { videoIdOrUUID: number | string }) => Promise<void>
82 }
83
84 server: {
85 getServerActor: () => Promise<ActorModel>
86 }
87
88 plugin: {
89 // PeerTube >= 3.2
90 getBaseStaticRoute: () => string
91
92 // PeerTube >= 3.2
93 getBaseRouterRoute: () => string
94
95 // PeerTube >= 3.2
96 getDataDirectoryPath: () => string
97 }
98
99 user: {
100 // PeerTube >= 3.2
101 getAuthUser: (response: Response) => Promise<{
102 id?: string
103 username: string
104 email: string
105 blocked: boolean
106 role: UserRole
107 } | undefined>
108 }
109 }
110
111 export type RegisterServerOptions = {
112 registerHook: (options: RegisterServerHookOptions) => void
113
114 registerSetting: (options: RegisterServerSettingOptions) => void
115
116 settingsManager: PluginSettingsManager
117
118 storageManager: PluginStorageManager
119
120 videoCategoryManager: PluginVideoCategoryManager
121 videoLanguageManager: PluginVideoLanguageManager
122 videoLicenceManager: PluginVideoLicenceManager
123
124 videoPrivacyManager: PluginVideoPrivacyManager
125 playlistPrivacyManager: PluginPlaylistPrivacyManager
126
127 transcodingManager: PluginTranscodingManager
128
129 registerIdAndPassAuth: (options: RegisterServerAuthPassOptions) => void
130 registerExternalAuth: (options: RegisterServerAuthExternalOptions) => RegisterServerAuthExternalResult
131 unregisterIdAndPassAuth: (authName: string) => void
132 unregisterExternalAuth: (authName: string) => void
133
134 // Get plugin router to create custom routes
135 // Base routes of this router are
136 // * /plugins/:pluginName/:pluginVersion/router/...
137 // * /plugins/:pluginName/router/...
138 getRouter(): Router
139
140 peertubeHelpers: PeerTubeHelpers
141 }