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