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