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
74 getServerConfig: () => Promise<ServerConfig>
78 blockServer: (options: { byAccountId: number, hostToBlock: string }) => Promise<void>
79 unblockServer: (options: { byAccountId: number, hostToUnblock: string }) => Promise<void>
80 blockAccount: (options: { byAccountId: number, handleToBlock: string }) => Promise<void>
81 unblockAccount: (options: { byAccountId: number, handleToUnblock: string }) => Promise<void>
83 blacklistVideo: (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => Promise<void>
84 unblacklistVideo: (options: { videoIdOrUUID: number | string }) => Promise<void>
89 getHTTPServer: () => Server
91 getServerActor: () => Promise<ActorModel>
95 sendNotification: (userId: number, notification: UserNotificationModelForApi) => void
96 sendVideoLiveNewState: (video: MVideo) => void
101 getBaseStaticRoute: () => string
104 getBaseRouterRoute: () => string
106 getBaseWebSocketRoute: () => string
109 getDataDirectoryPath: () => string
114 getAuthUser: (response: Response) => Promise<MUserDefault>
117 loadById: (id: number) => Promise<MUserDefault>
121 export type RegisterServerOptions = {
122 registerHook: (options: RegisterServerHookOptions) => void
124 registerSetting: (options: RegisterServerSettingOptions) => void
126 settingsManager: PluginSettingsManager
128 storageManager: PluginStorageManager
130 videoCategoryManager: PluginVideoCategoryManager
131 videoLanguageManager: PluginVideoLanguageManager
132 videoLicenceManager: PluginVideoLicenceManager
134 videoPrivacyManager: PluginVideoPrivacyManager
135 playlistPrivacyManager: PluginPlaylistPrivacyManager
137 transcodingManager: PluginTranscodingManager
139 registerIdAndPassAuth: (options: RegisterServerAuthPassOptions) => void
140 registerExternalAuth: (options: RegisterServerAuthExternalOptions) => RegisterServerAuthExternalResult
141 unregisterIdAndPassAuth: (authName: string) => void
142 unregisterExternalAuth: (authName: string) => void
144 // Get plugin router to create custom routes
145 // Base routes of this router are
146 // * /plugins/:pluginName/:pluginVersion/router/...
147 // * /plugins/:pluginName/router/...
151 // Register WebSocket route
152 // Base routes of the WebSocket router are
153 // * /plugins/:pluginName/:pluginVersion/ws/...
154 // * /plugins/:pluginName/ws/...
155 registerWebSocketRoute: (options: RegisterServerWebSocketRouteOptions) => void
157 peertubeHelpers: PeerTubeHelpers