mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
Add ability for plugins to register ws routes
This commit is contained in:
parent
9866921cbf
commit
9d4c60dccc
16 changed files with 262 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
|||
import express from 'express'
|
||||
import { Server } from 'http'
|
||||
import { join } from 'path'
|
||||
import { ffprobePromise } from '@server/helpers/ffmpeg/ffprobe-utils'
|
||||
import { buildLogger } from '@server/helpers/logger'
|
||||
|
@ -17,12 +18,12 @@ import { MPlugin, MVideo, UserNotificationModelForApi } from '@server/types/mode
|
|||
import { PeerTubeHelpers } from '@server/types/plugins'
|
||||
import { VideoBlacklistCreate, VideoStorage } from '@shared/models'
|
||||
import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../blocklist'
|
||||
import { PeerTubeSocket } from '../peertube-socket'
|
||||
import { ServerConfigManager } from '../server-config-manager'
|
||||
import { blacklistVideo, unblacklistVideo } from '../video-blacklist'
|
||||
import { VideoPathManager } from '../video-path-manager'
|
||||
import { PeerTubeSocket } from '../peertube-socket'
|
||||
|
||||
function buildPluginHelpers (pluginModel: MPlugin, npmName: string): PeerTubeHelpers {
|
||||
function buildPluginHelpers (httpServer: Server, pluginModel: MPlugin, npmName: string): PeerTubeHelpers {
|
||||
const logger = buildPluginLogger(npmName)
|
||||
|
||||
const database = buildDatabaseHelpers()
|
||||
|
@ -30,7 +31,7 @@ function buildPluginHelpers (pluginModel: MPlugin, npmName: string): PeerTubeHel
|
|||
|
||||
const config = buildConfigHelpers()
|
||||
|
||||
const server = buildServerHelpers()
|
||||
const server = buildServerHelpers(httpServer)
|
||||
|
||||
const moderation = buildModerationHelpers()
|
||||
|
||||
|
@ -69,8 +70,10 @@ function buildDatabaseHelpers () {
|
|||
}
|
||||
}
|
||||
|
||||
function buildServerHelpers () {
|
||||
function buildServerHelpers (httpServer: Server) {
|
||||
return {
|
||||
getHTTPServer: () => httpServer,
|
||||
|
||||
getServerActor: () => getServerActor()
|
||||
}
|
||||
}
|
||||
|
@ -218,6 +221,8 @@ function buildPluginRelatedHelpers (plugin: MPlugin, npmName: string) {
|
|||
|
||||
getBaseRouterRoute: () => `/plugins/${plugin.name}/${plugin.version}/router/`,
|
||||
|
||||
getBaseWebSocketRoute: () => `/plugins/${plugin.name}/${plugin.version}/ws/`,
|
||||
|
||||
getDataDirectoryPath: () => join(CONFIG.STORAGE.PLUGINS_DIR, 'data', npmName)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue