1 import { Response, Router } from 'express'
2 import { Server } from 'http'
3 import { Logger } from 'winston'
4 import { ActorModel } from '@server/models/actor/actor'
6 PluginPlaylistPrivacyManager,
9 PluginTranscodingManager,
10 PluginVideoCategoryManager,
11 PluginVideoLanguageManager,
12 PluginVideoLicenceManager,
13 PluginVideoPrivacyManager,
14 RegisterServerHookOptions,
15 RegisterServerSettingOptions,
19 } from '@shared/models'
20 import { MUserDefault, MVideo, MVideoThumbnail, UserNotificationModelForApi } from '../models'
22 RegisterServerAuthExternalOptions,
23 RegisterServerAuthExternalResult,
24 RegisterServerAuthPassOptions
25 } from './register-server-auth.model'
26 import { RegisterServerWebSocketRouteOptions } from './register-server-websocket-route.model'
28 export type PeerTubeHelpers = {
36 loadByUrl: (url: string) => Promise<MVideoThumbnail>
37 loadByIdOrUUID: (id: number | string) => Promise<MVideoThumbnail>
39 removeVideo: (videoId: number) => Promise<void>
41 ffprobe: (path: string) => Promise<any>
43 getFiles: (id: number | string) => Promise<{
46 path: string // Could be null if using remote storage
56 path: string // Could be null if using remote storage
72 getWebserverUrl: () => string
75 getServerListeningConfig: () => { hostname: string, port: number }
77 getServerConfig: () => Promise<ServerConfig>
81 blockServer: (options: { byAccountId: number, hostToBlock: string }) => Promise<void>
82 unblockServer: (options: { byAccountId: number, hostToUnblock: string }) => Promise<void>
83 blockAccount: (options: { byAccountId: number, handleToBlock: string }) => Promise<void>
84 unblockAccount: (options: { byAccountId: number, handleToUnblock: string }) => Promise<void>
86 blacklistVideo: (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => Promise<void>
87 unblacklistVideo: (options: { videoIdOrUUID: number | string }) => Promise<void>
92 getHTTPServer: () => Server
94 getServerActor: () => Promise<ActorModel>
98 sendNotification: (userId: number, notification: UserNotificationModelForApi) => void
99 sendVideoLiveNewState: (video: MVideo) => void
104 getBaseStaticRoute: () => string
107 getBaseRouterRoute: () => string
109 getBaseWebSocketRoute: () => string
112 getDataDirectoryPath: () => string
117 getAuthUser: (response: Response) => Promise<MUserDefault>
120 loadById: (id: number) => Promise<MUserDefault>
124 export type RegisterServerOptions = {
125 registerHook: (options: RegisterServerHookOptions) => void
127 registerSetting: (options: RegisterServerSettingOptions) => void
129 settingsManager: PluginSettingsManager
131 storageManager: PluginStorageManager
133 videoCategoryManager: PluginVideoCategoryManager
134 videoLanguageManager: PluginVideoLanguageManager
135 videoLicenceManager: PluginVideoLicenceManager
137 videoPrivacyManager: PluginVideoPrivacyManager
138 playlistPrivacyManager: PluginPlaylistPrivacyManager
140 transcodingManager: PluginTranscodingManager
142 registerIdAndPassAuth: (options: RegisterServerAuthPassOptions) => void
143 registerExternalAuth: (options: RegisterServerAuthExternalOptions) => RegisterServerAuthExternalResult
144 unregisterIdAndPassAuth: (authName: string) => void
145 unregisterExternalAuth: (authName: string) => void
147 // Get plugin router to create custom routes
148 // Base routes of this router are
149 // * /plugins/:pluginName/:pluginVersion/router/...
150 // * /plugins/:pluginName/router/...
154 // Register WebSocket route
155 // Base routes of the WebSocket router are
156 // * /plugins/:pluginName/:pluginVersion/ws/...
157 // * /plugins/:pluginName/ws/...
158 registerWebSocketRoute: (options: RegisterServerWebSocketRouteOptions) => void
160 peertubeHelpers: PeerTubeHelpers