8f1d66007df44e46aaef41332e03d07a3ca8e358
[oweals/peertube.git] / server / typings / plugins / register-server-option.model.ts
1 import * as Bluebird from 'bluebird'
2 import { Router } from 'express'
3 import { Logger } from 'winston'
4 import { ActorModel } from '@server/models/activitypub/actor'
5 import { VideoBlacklistCreate } from '@shared/models'
6 import { PluginPlaylistPrivacyManager } from '@shared/models/plugins/plugin-playlist-privacy-manager.model'
7 import { PluginVideoPrivacyManager } from '@shared/models/plugins/plugin-video-privacy-manager.model'
8 import {
9   RegisterServerAuthExternalOptions,
10   RegisterServerAuthExternalResult,
11   RegisterServerAuthPassOptions
12 } from '@shared/models/plugins/register-server-auth.model'
13 import { PluginSettingsManager } from '../../../shared/models/plugins/plugin-settings-manager.model'
14 import { PluginStorageManager } from '../../../shared/models/plugins/plugin-storage-manager.model'
15 import { PluginVideoCategoryManager } from '../../../shared/models/plugins/plugin-video-category-manager.model'
16 import { PluginVideoLanguageManager } from '../../../shared/models/plugins/plugin-video-language-manager.model'
17 import { PluginVideoLicenceManager } from '../../../shared/models/plugins/plugin-video-licence-manager.model'
18 import { RegisterServerHookOptions } from '../../../shared/models/plugins/register-server-hook.model'
19 import { RegisterServerSettingOptions } from '../../../shared/models/plugins/register-server-setting.model'
20 import { MVideoThumbnail } from '../models'
21
22 export type PeerTubeHelpers = {
23   logger: Logger
24
25   database: {
26     query: Function
27   }
28
29   videos: {
30     loadByUrl: (url: string) => Bluebird<MVideoThumbnail>
31
32     removeVideo: (videoId: number) => Promise<void>
33   }
34
35   config: {
36     getWebserverUrl: () => string
37   }
38
39   moderation: {
40     blockServer: (options: { byAccountId: number, hostToBlock: string }) => Promise<void>
41     unblockServer: (options: { byAccountId: number, hostToUnblock: string }) => Promise<void>
42     blockAccount: (options: { byAccountId: number, handleToBlock: string }) => Promise<void>
43     unblockAccount: (options: { byAccountId: number, handleToUnblock: string }) => Promise<void>
44
45     blacklistVideo: (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => Promise<void>
46     unblacklistVideo: (options: { videoIdOrUUID: number | string }) => Promise<void>
47   }
48
49   server: {
50     getServerActor: () => Promise<ActorModel>
51   }
52 }
53
54 export type RegisterServerOptions = {
55   registerHook: (options: RegisterServerHookOptions) => void
56
57   registerSetting: (options: RegisterServerSettingOptions) => void
58
59   settingsManager: PluginSettingsManager
60
61   storageManager: PluginStorageManager
62
63   videoCategoryManager: PluginVideoCategoryManager
64   videoLanguageManager: PluginVideoLanguageManager
65   videoLicenceManager: PluginVideoLicenceManager
66
67   videoPrivacyManager: PluginVideoPrivacyManager
68   playlistPrivacyManager: PluginPlaylistPrivacyManager
69
70   registerIdAndPassAuth: (options: RegisterServerAuthPassOptions) => void
71   registerExternalAuth: (options: RegisterServerAuthExternalOptions) => RegisterServerAuthExternalResult
72   unregisterIdAndPassAuth: (authName: string) => void
73   unregisterExternalAuth: (authName: string) => void
74
75   // Get plugin router to create custom routes
76   // Base routes of this router are
77   //  * /plugins/:pluginName/:pluginVersion/router/...
78   //  * /plugins/:pluginName/router/...
79   getRouter(): Router
80
81   peertubeHelpers: PeerTubeHelpers
82 }