Removing a hack:
* replacing loadByUrl by loadByIdOrUuid * breaks compatibility with peertube 3.0.1 * simpler webchat route * fix uuid escaping in iframe uri
This commit is contained in:
parent
fbfd86aab0
commit
9dc0ce6383
@ -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.
|
* Builtin Prosody: use mod_muc_http_defaults to set rooms properties and prevent unauthorized room creation.
|
||||||
|
|
||||||
## v2.0.3
|
## v2.0.3
|
||||||
|
@ -43,16 +43,10 @@ function register ({ registerHook, peertubeHelpers }: RegisterOptions): void {
|
|||||||
let iframeUri = ''
|
let iframeUri = ''
|
||||||
if (settings['chat-use-prosody'] || settings['chat-use-builtin']) {
|
if (settings['chat-use-prosody'] || settings['chat-use-builtin']) {
|
||||||
// Using the builtin converseJS
|
// Using the builtin converseJS
|
||||||
// FIXME: with Peertube 3.0.1 there is no loadByIdOrUUID method,
|
iframeUri = getBaseRoute() + '/webchat/room/' + encodeURIComponent(uuid)
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
} else if (!settings['chat-use-builtin']) {
|
} else if (!settings['chat-use-builtin']) {
|
||||||
iframeUri = settings['chat-uri'] || ''
|
iframeUri = settings['chat-uri'] || ''
|
||||||
iframeUri = iframeUri.replace(/{{VIDEO_UUID}}/g, uuid)
|
iframeUri = iframeUri.replace(/{{VIDEO_UUID}}/g, encodeURIComponent(uuid))
|
||||||
if (!/^https?:\/\//.test(iframeUri)) {
|
if (!/^https?:\/\//.test(iframeUri)) {
|
||||||
logger.error('The webchaturi must begin with https://')
|
logger.error('The webchaturi must begin with https://')
|
||||||
return null
|
return null
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
"webpack-cli": "^3.3.10"
|
"webpack-cli": "^3.3.10"
|
||||||
},
|
},
|
||||||
"engine": {
|
"engine": {
|
||||||
"peertube": ">=3.0.1"
|
"peertube": ">=3.1.0"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/JohnXLivingston/peertube-plugin-livechat",
|
"homepage": "https://github.com/JohnXLivingston/peertube-plugin-livechat",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
2
server/@types/peertube.d.ts
vendored
2
server/@types/peertube.d.ts
vendored
@ -57,7 +57,7 @@ interface PeerTubeHelpers {
|
|||||||
videos: {
|
videos: {
|
||||||
loadByUrl: (url: string) => Promise<MVideoThumbnail>
|
loadByUrl: (url: string) => Promise<MVideoThumbnail>
|
||||||
// NB: loadByIdOrUUID was introduced in v3.1.0
|
// NB: loadByIdOrUUID was introduced in v3.1.0
|
||||||
loadByIdOrUUID?: (id: number | string) => Promise<MVideoThumbnail>
|
loadByIdOrUUID: (id: number | string) => Promise<MVideoThumbnail>
|
||||||
removeVideo: (videoId: number) => Promise<void>
|
removeVideo: (videoId: number) => Promise<void>
|
||||||
}
|
}
|
||||||
config: {
|
config: {
|
||||||
|
@ -20,7 +20,7 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
|
|||||||
|
|
||||||
const router: Router = getRouter()
|
const router: Router = getRouter()
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
router.get('/', async (req: Request, res: Response, next: NextFunction): Promise<void> => {
|
router.get('/room/:videoUUID', async (req: Request, res: Response, next: NextFunction): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const settings = await settingsManager.getSettings([
|
const settings = await settingsManager.getSettings([
|
||||||
'chat-use-prosody', 'chat-use-builtin', 'chat-room', 'chat-server',
|
'chat-use-prosody', 'chat-use-builtin', 'chat-room', 'chat-server',
|
||||||
@ -54,29 +54,15 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
|
|||||||
throw new Error('Builtin chat disabled.')
|
throw new Error('Builtin chat disabled.')
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: with Peertube 3.0.1 the following method is not available...
|
const uuid = req.params.videoUUID
|
||||||
// When loadByIdOrUUID is available, change the entry point to
|
const video = await peertubeHelpers.videos.loadByIdOrUUID(uuid)
|
||||||
// be /webchat/:videoId
|
|
||||||
// const id = req.param('videoId')
|
|
||||||
// const video = await peertubeHelpers.videos.loadByIdOrUUID(id)
|
|
||||||
let url: string = req.query.url as string || ''
|
|
||||||
if (!url) {
|
|
||||||
throw new Error('Missing url parameter)')
|
|
||||||
}
|
|
||||||
let video = await peertubeHelpers.videos.loadByUrl(url)
|
|
||||||
if (!video) {
|
|
||||||
// FIXME: remove this when loadByIdOrUUID will be available...
|
|
||||||
// This is a dirty Hack for dev environnements...
|
|
||||||
url = url.replace(/^https:/, 'http:')
|
|
||||||
video = await peertubeHelpers.videos.loadByUrl(url)
|
|
||||||
}
|
|
||||||
if (!video) {
|
if (!video) {
|
||||||
throw new Error('Video not found')
|
throw new Error('Video not found')
|
||||||
}
|
}
|
||||||
|
|
||||||
let page = '' + (converseJSIndex as string)
|
let page = '' + (converseJSIndex as string)
|
||||||
// FIXME: Peertube should provide the static folder path. For now:
|
// FIXME: Peertube should provide the static folder path. For now:
|
||||||
const staticRelative = '../static'
|
const staticRelative = '../../../static'
|
||||||
page = page.replace(/{{BASE_STATIC_URL}}/g, staticRelative)
|
page = page.replace(/{{BASE_STATIC_URL}}/g, staticRelative)
|
||||||
page = page.replace(/{{JID}}/g, server)
|
page = page.replace(/{{JID}}/g, server)
|
||||||
room = room.replace(/{{VIDEO_UUID}}/g, video.uuid)
|
room = room.replace(/{{VIDEO_UUID}}/g, video.uuid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user