Chat Federation: fetch remote server information when missing.
This commit is contained in:
@ -10,6 +10,7 @@ import { getProsodyDomain } from '../prosody/config/domain'
|
||||
import { fillVideoCustomFields } from '../custom-fields'
|
||||
import { getChannelInfosById } from '../database/channel'
|
||||
import { ensureProsodyRunning } from '../prosody/ctl'
|
||||
import { serverBuildInfos } from '../federation/outgoing'
|
||||
import { isDebugMode } from '../debug'
|
||||
|
||||
// See here for description: https://modules.prosody.im/mod_muc_http_defaults.html
|
||||
@ -224,14 +225,13 @@ async function initApiRouter (options: RegisterServerOptions): Promise<Router> {
|
||||
}
|
||||
))
|
||||
|
||||
// router.get('/federation_server_infos', asyncMiddleware(
|
||||
// async (req: Request, res: Response, _next: NextFunction) => {
|
||||
// logger.info('federation_server_infos api call')
|
||||
// // TODO/FIXME: return server infos.
|
||||
// // TODO/FIXME: store these informations on the other side.
|
||||
// res.json({ ok: true })
|
||||
// }
|
||||
// ))
|
||||
router.get('/federation_server_infos', asyncMiddleware(
|
||||
async (req: Request, res: Response, _next: NextFunction) => {
|
||||
logger.info('federation_server_infos api call')
|
||||
const result = await serverBuildInfos(options)
|
||||
res.json(result)
|
||||
}
|
||||
))
|
||||
|
||||
if (isDebugMode(options)) {
|
||||
// Only add this route if the debug mode is enabled at time of the server launch.
|
||||
|
@ -18,7 +18,7 @@ import { LiveChatJSONLDAttributeV1 } from '../federation/types'
|
||||
import {
|
||||
anonymousConnectionInfos, compatibleRemoteAuthenticatedConnectionEnabled
|
||||
} from '../federation/connection-infos'
|
||||
// import { remoteServerInfos } from '../federation/remote-infos'
|
||||
import { fetchMissingRemoteServerInfos } from '../federation/fetch-infos'
|
||||
import * as path from 'path'
|
||||
const got = require('got')
|
||||
|
||||
@ -290,11 +290,11 @@ async function initWebchatRouter (options: RegisterServerOptionsV5): Promise<Rou
|
||||
// If the incomming request is from a remote Peertube instance, we must ensure that we know
|
||||
// how to connect to it using Websocket S2S (for the dialback mecanism).
|
||||
const remoteInstanceUrl = request.headers['peertube-livechat-ws-s2s-instance-url']
|
||||
if (remoteInstanceUrl && (typeof remoteInstanceUrl !== 'string')) {
|
||||
// Note: remoteServerInfos will store the information,
|
||||
if (remoteInstanceUrl && (typeof remoteInstanceUrl === 'string')) {
|
||||
// Note: fetchMissingRemoteServerInfos will store the information,
|
||||
// so that the Prosody mod_s2s_peertubelivechat module can access them.
|
||||
// TODO
|
||||
// await remoteServerInfos(options, remoteInstanceUrl)
|
||||
// We dont need to read the result.
|
||||
await fetchMissingRemoteServerInfos(options, remoteInstanceUrl)
|
||||
}
|
||||
currentS2SWebsocketProxy.ws(request, socket, head)
|
||||
} catch (err) {
|
||||
|
Reference in New Issue
Block a user