mod_muc_http_defaults WIP.
This commit is contained in:
parent
a4d671bf50
commit
c19035c0b7
@ -1,6 +1,6 @@
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { pluginName } from '../helpers'
|
||||
import { pluginName, getBaseRouter } from '../helpers'
|
||||
|
||||
type LogMode = 'debug' | 'info'
|
||||
|
||||
@ -114,15 +114,15 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
|
||||
|
||||
const mucModules: ProsodyModuleConfig[] = []
|
||||
|
||||
// mucModules.push({
|
||||
// module: 'muc_http_defaults',
|
||||
// options: [
|
||||
// {
|
||||
// name: 'muc_create_api_url',
|
||||
// value: '' // FIXME
|
||||
// }
|
||||
// ]
|
||||
// })
|
||||
mucModules.push({
|
||||
module: 'muc_http_defaults',
|
||||
options: [
|
||||
{
|
||||
name: 'muc_create_api_url',
|
||||
value: options.peertubeHelpers.config.getWebserverUrl() + getBaseRouter() + 'api/room'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const mucModulesEnabled: string = mucModules.map(m => ' "' + m.module + '";').join('\n')
|
||||
const mucModulesOptions: string = mucModules.map(m => {
|
||||
|
43
server/lib/routers/api.ts
Normal file
43
server/lib/routers/api.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import type { Router, Request, Response, NextFunction } from 'express'
|
||||
|
||||
// See here for description: https://modules.prosody.im/mod_muc_http_defaults.html
|
||||
interface RoomDefaults {
|
||||
name: string
|
||||
description: string
|
||||
// language: string
|
||||
// persistent: boolean
|
||||
public: boolean
|
||||
// members_only: boolean
|
||||
// allow_member_invites: boolean
|
||||
// public_jids: boolean
|
||||
subject: string
|
||||
// changesubject: boolean
|
||||
// // historylength: number
|
||||
// moderated: boolean
|
||||
// archiving: boolean
|
||||
// affiliations: RoomAffiliation[]
|
||||
}
|
||||
|
||||
async function initApiRouter (options: RegisterServerOptions): Promise<Router> {
|
||||
const { peertubeHelpers, getRouter } = options
|
||||
const router = getRouter()
|
||||
const logger = peertubeHelpers.logger
|
||||
|
||||
router.get('/room', async (_req: Request, res: Response, _next: NextFunction) => {
|
||||
logger.info('Requesting room information for room ...')
|
||||
// TODO: check if room is legit and fill informations
|
||||
const roomDefaults: RoomDefaults = {
|
||||
name: 'name_of_the_room',
|
||||
description: 'room description',
|
||||
public: false,
|
||||
subject: 'subject'
|
||||
}
|
||||
res.json(roomDefaults)
|
||||
})
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
export {
|
||||
initApiRouter
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import type { NextFunction, Request, Response } from 'express'
|
||||
import { initWebchatRouter } from './webchat'
|
||||
import { initSettingsRouter } from './settings'
|
||||
import { initApiRouter } from './api'
|
||||
|
||||
async function initRouters (options: RegisterServerOptions): Promise<void> {
|
||||
const { getRouter } = options
|
||||
@ -10,6 +11,7 @@ async function initRouters (options: RegisterServerOptions): Promise<void> {
|
||||
|
||||
router.use('/webchat', await initWebchatRouter(options))
|
||||
router.use('/settings', await initSettingsRouter(options))
|
||||
router.use('/api', await initApiRouter(options))
|
||||
}
|
||||
|
||||
export {
|
||||
|
Loading…
x
Reference in New Issue
Block a user