1 import { Response, Router } from 'express'
2 import { Logger } from 'winston'
3 import { ActorModel } from '@server/models/actor/actor'
5 PluginPlaylistPrivacyManager,
8 PluginTranscodingManager,
9 PluginVideoCategoryManager,
10 PluginVideoLanguageManager,
11 PluginVideoLicenceManager,
12 PluginVideoPrivacyManager,
13 RegisterServerHookOptions,
14 RegisterServerSettingOptions,
18 } from '@shared/models'
19 import { MUserDefault, MVideo, MVideoThumbnail, UserNotificationModelForApi } from '../models'
21 RegisterServerAuthExternalOptions,
22 RegisterServerAuthExternalResult,
23 RegisterServerAuthPassOptions
24 } from './register-server-auth.model'
26 export type PeerTubeHelpers = {
34 loadByUrl: (url: string) => Promise<MVideoThumbnail>
35 loadByIdOrUUID: (id: number | string) => Promise<MVideoThumbnail>
37 removeVideo: (videoId: number) => Promise<void>
39 ffprobe: (path: string) => Promise<any>
41 getFiles: (id: number | string) => Promise<{
44 path: string // Could be null if using remote storage
54 path: string // Could be null if using remote storage
70 getWebserverUrl: () => string
72 getServerConfig: () => Promise<ServerConfig>
76 blockServer: (options: { byAccountId: number, hostToBlock: string }) => Promise<void>
77 unblockServer: (options: { byAccountId: number, hostToUnblock: string }) => Promise<void>
78 blockAccount: (options: { byAccountId: number, handleToBlock: string }) => Promise<void>
79 unblockAccount: (options: { byAccountId: number, handleToUnblock: string }) => Promise<void>
81 blacklistVideo: (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => Promise<void>
82 unblacklistVideo: (options: { videoIdOrUUID: number | string }) => Promise<void>
86 getServerActor: () => Promise<ActorModel>
90 sendNotification: (userId: number, notification: UserNotificationModelForApi) => void
91 sendVideoLiveNewState: (video: MVideo) => void
96 getBaseStaticRoute: () => string
99 getBaseRouterRoute: () => string
102 getDataDirectoryPath: () => string
107 getAuthUser: (response: Response) => Promise<MUserDefault>
110 loadById: (id: number) => Promise<MUserDefault>
114 export type RegisterServerOptions = {
115 registerHook: (options: RegisterServerHookOptions) => void
117 registerSetting: (options: RegisterServerSettingOptions) => void
119 settingsManager: PluginSettingsManager
121 storageManager: PluginStorageManager
123 videoCategoryManager: PluginVideoCategoryManager
124 videoLanguageManager: PluginVideoLanguageManager
125 videoLicenceManager: PluginVideoLicenceManager
127 videoPrivacyManager: PluginVideoPrivacyManager
128 playlistPrivacyManager: PluginPlaylistPrivacyManager
130 transcodingManager: PluginTranscodingManager
132 registerIdAndPassAuth: (options: RegisterServerAuthPassOptions) => void
133 registerExternalAuth: (options: RegisterServerAuthExternalOptions) => RegisterServerAuthExternalResult
134 unregisterIdAndPassAuth: (authName: string) => void
135 unregisterExternalAuth: (authName: string) => void
137 // Get plugin router to create custom routes
138 // Base routes of this router are
139 // * /plugins/:pluginName/:pluginVersion/router/...
140 // * /plugins/:pluginName/router/...
143 peertubeHelpers: PeerTubeHelpers