diff --git a/CHANGELOG.md b/CHANGELOG.md index 655afb6a..df38cf82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## ??? +### Important Notes + +* This version requires at least Peertube version 3.1.0. It is no more compatible with Peertube 3.0.1. + +### Features + * Builtin Prosody: use mod_muc_http_defaults to set rooms properties and prevent unauthorized room creation. ## v2.0.3 diff --git a/client/videowatch-client-plugin.ts b/client/videowatch-client-plugin.ts index 6e6df72a..caa51d20 100644 --- a/client/videowatch-client-plugin.ts +++ b/client/videowatch-client-plugin.ts @@ -43,16 +43,10 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void { let iframeUri = '' if (settings['chat-use-prosody'] || settings['chat-use-builtin']) { // Using the builtin converseJS - // FIXME: with Peertube 3.0.1 there is no loadByIdOrUUID method, - // we need to pass the complete url. - const video = videoCache[uuid] - if (video) { - const url: string = video.originInstanceUrl + '/videos/watch/' + uuid - iframeUri = getBaseRoute() + '/webchat?url=' + encodeURIComponent(url) - } + iframeUri = getBaseRoute() + '/webchat/room/' + encodeURIComponent(uuid) } else if (!settings['chat-use-builtin']) { iframeUri = settings['chat-uri'] || '' - iframeUri = iframeUri.replace(/{{VIDEO_UUID}}/g, uuid) + iframeUri = iframeUri.replace(/{{VIDEO_UUID}}/g, encodeURIComponent(uuid)) if (!/^https?:\/\//.test(iframeUri)) { logger.error('The webchaturi must begin with https://') return null diff --git a/package.json b/package.json index d8e441f9..14f11d50 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "webpack-cli": "^3.3.10" }, "engine": { - "peertube": ">=3.0.1" + "peertube": ">=3.1.0" }, "homepage": "https://github.com/JohnXLivingston/peertube-plugin-livechat", "keywords": [ diff --git a/server/@types/peertube.d.ts b/server/@types/peertube.d.ts index 02ff1dc7..c00078ec 100644 --- a/server/@types/peertube.d.ts +++ b/server/@types/peertube.d.ts @@ -57,7 +57,7 @@ interface PeerTubeHelpers { videos: { loadByUrl: (url: string) => Promise // NB: loadByIdOrUUID was introduced in v3.1.0 - loadByIdOrUUID?: (id: number | string) => Promise + loadByIdOrUUID: (id: number | string) => Promise removeVideo: (videoId: number) => Promise } config: { diff --git a/server/lib/routers/webchat.ts b/server/lib/routers/webchat.ts index 3d54f9d5..cab7599c 100644 --- a/server/lib/routers/webchat.ts +++ b/server/lib/routers/webchat.ts @@ -20,7 +20,7 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise => { + router.get('/room/:videoUUID', async (req: Request, res: Response, next: NextFunction): Promise => { try { const settings = await settingsManager.getSettings([ 'chat-use-prosody', 'chat-use-builtin', 'chat-room', 'chat-server', @@ -54,29 +54,15 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise