]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/types/plugins/register-server-option.model.ts
fb4f12a4c45ed884a8143807eb227e4f4bf34604
[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, MVideoThumbnail } 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 plugin: {
90 // PeerTube >= 3.2
91 getBaseStaticRoute: () => string
92
93 // PeerTube >= 3.2
94 getBaseRouterRoute: () => string
95
96 // PeerTube >= 3.2
97 getDataDirectoryPath: () => string
98 }
99
100 user: {
101 // PeerTube >= 3.2
102 getAuthUser: (response: Response) => Promise<MUserDefault>
103
104 // PeerTube >= 4.3
105 loadById: (id: number) => Promise<MUserDefault>
106 }
107 }
108
109 export type RegisterServerOptions = {
110 registerHook: (options: RegisterServerHookOptions) => void
111
112 registerSetting: (options: RegisterServerSettingOptions) => void
113
114 settingsManager: PluginSettingsManager
115
116 storageManager: PluginStorageManager
117
118 videoCategoryManager: PluginVideoCategoryManager
119 videoLanguageManager: PluginVideoLanguageManager
120 videoLicenceManager: PluginVideoLicenceManager
121
122 videoPrivacyManager: PluginVideoPrivacyManager
123 playlistPrivacyManager: PluginPlaylistPrivacyManager
124
125 transcodingManager: PluginTranscodingManager
126
127 registerIdAndPassAuth: (options: RegisterServerAuthPassOptions) => void
128 registerExternalAuth: (options: RegisterServerAuthExternalOptions) => RegisterServerAuthExternalResult
129 unregisterIdAndPassAuth: (authName: string) => void
130 unregisterExternalAuth: (authName: string) => void
131
132 // Get plugin router to create custom routes
133 // Base routes of this router are
134 // * /plugins/:pluginName/:pluginVersion/router/...
135 // * /plugins/:pluginName/router/...
136 getRouter(): Router
137
138 peertubeHelpers: PeerTubeHelpers
139 }