Adding a Shared folder:

* init some shared functions (videoHasWebchat, parseConfigUUIDs)
* api/room: checking that video has live enabled
* fix promise handling in initChat function
* removing some 'use strict' that are no more necessary in typescript
This commit is contained in:
John Livingston
2021-05-01 18:30:21 +02:00
parent 0cc57dfc12
commit ef05583fba
9 changed files with 145 additions and 24 deletions

View File

@ -1,4 +1,5 @@
import type { Router, Request, Response, NextFunction } from 'express'
import { videoHasWebchat } from '../../../shared/lib/video'
// See here for description: https://modules.prosody.im/mod_muc_http_defaults.html
interface RoomDefaults {
@ -38,9 +39,23 @@ async function initApiRouter (options: RegisterServerOptions): Promise<Router> {
if (!video) {
throw new Error('Video not found')
}
// FIXME: check settings (chat enabled for this video)
// check settings (chat enabled for this video?)
const settings = await options.settingsManager.getSettings([
'chat-only-locals',
'chat-all-lives',
'chat-all-non-lives',
'chat-videos-list'
])
if (!videoHasWebchat({
'chat-only-locals': settings['chat-only-locals'] as boolean,
'chat-all-lives': settings['chat-all-lives'] as boolean,
'chat-all-non-lives': settings['chat-all-non-lives'] as boolean,
'chat-videos-list': settings['chat-videos-list'] as string
}, video)) {
throw new Error('Chat is not activated for this video')
}
// TODO: check if room is legit and fill informations
// TODO: fill missing informations
const roomDefaults: RoomDefaults = {
config: {
name: video.name,

View File

@ -15,9 +15,12 @@
"sourceMap": true,
"baseUrl": "./",
"outDir": "../dist/server",
"outDir": "../dist/",
"paths": {}
},
"include": ["./**/*"],
"include": [
"./**/*",
"../shared/**/*"
],
"exclude": []
}