]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/types/plugins/register-server-option.model.ts
Merge branch 'develop' into shorter-URLs-channels-accounts
[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 UserRole,
17 VideoBlacklistCreate
18 } from '@shared/models'
19 import { 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
40 config: {
41 getWebserverUrl: () => string
42
43 getServerConfig: () => Promise<ServerConfig>
44 }
45
46 moderation: {
47 blockServer: (options: { byAccountId: number, hostToBlock: string }) => Promise<void>
48 unblockServer: (options: { byAccountId: number, hostToUnblock: string }) => Promise<void>
49 blockAccount: (options: { byAccountId: number, handleToBlock: string }) => Promise<void>
50 unblockAccount: (options: { byAccountId: number, handleToUnblock: string }) => Promise<void>
51
52 blacklistVideo: (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => Promise<void>
53 unblacklistVideo: (options: { videoIdOrUUID: number | string }) => Promise<void>
54 }
55
56 server: {
57 getServerActor: () => Promise<ActorModel>
58 }
59
60 plugin: {
61 // PeerTube >= 3.2
62 getBaseStaticRoute: () => string
63
64 // PeerTube >= 3.2
65 getBaseRouterRoute: () => string
66
67 // PeerTube >= 3.2
68 getDataDirectoryPath: () => string
69 }
70
71 user: {
72 // PeerTube >= 3.2
73 getAuthUser: (response: Response) => Promise<{
74 id?: string
75 username: string
76 email: string
77 blocked: boolean
78 role: UserRole
79 } | undefined>
80 }
81 }
82
83 export type RegisterServerOptions = {
84 registerHook: (options: RegisterServerHookOptions) => void
85
86 registerSetting: (options: RegisterServerSettingOptions) => void
87
88 settingsManager: PluginSettingsManager
89
90 storageManager: PluginStorageManager
91
92 videoCategoryManager: PluginVideoCategoryManager
93 videoLanguageManager: PluginVideoLanguageManager
94 videoLicenceManager: PluginVideoLicenceManager
95
96 videoPrivacyManager: PluginVideoPrivacyManager
97 playlistPrivacyManager: PluginPlaylistPrivacyManager
98
99 transcodingManager: PluginTranscodingManager
100
101 registerIdAndPassAuth: (options: RegisterServerAuthPassOptions) => void
102 registerExternalAuth: (options: RegisterServerAuthExternalOptions) => RegisterServerAuthExternalResult
103 unregisterIdAndPassAuth: (authName: string) => void
104 unregisterExternalAuth: (authName: string) => void
105
106 // Get plugin router to create custom routes
107 // Base routes of this router are
108 // * /plugins/:pluginName/:pluginVersion/router/...
109 // * /plugins/:pluginName/router/...
110 getRouter(): Router
111
112 peertubeHelpers: PeerTubeHelpers
113 }