Fix #48: Proper 404 and 403 pages when trying to open non-existant chatroom.:

* error page on the old endpoint, when anonymous users are disabled.
This commit is contained in:
John Livingston 2024-04-04 16:48:19 +02:00
parent 0719d25f35
commit 33bc346e83
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
3 changed files with 19 additions and 4 deletions

View File

@ -113,7 +113,8 @@ async function initConverse (
remoteRoomAnonymousParams(initConverseParams, auth, params)
isRemoteWithNicknameSet = true
} else {
throw new Error('Remote server does not allow remote connection')
console.error('Remote server does not allow remote connection')
params.jid = null
}
} else {
if (!isRemoteChat) {
@ -121,7 +122,21 @@ async function initConverse (
} else if (remoteAnonymousXMPPServer) {
remoteRoomAnonymousParams(initConverseParams, null, params)
} else {
throw new Error('Remote server does not allow remote connection')
console.error('Remote server does not allow remote connection')
params.jid = null
}
}
if (params.jid === null) {
if (chatIncludeMode === 'chat-only') {
// Special use case: when mode=chat-only, and no params.jid: display an error page.
// Note: this can happen if anonymous users are not allowed on the server.
console.error('Seems that anonymous users are not allowed on the target server')
// FIXME: localize?
document.body.innerHTML = '<h1>This chatroom does not exist, or is not accessible to you.</h1>'
return
} else {
throw new Error('Can\'t connect, no JID')
}
}

View File

@ -80,7 +80,7 @@ async function getConverseJSParams (
staticBaseUrl,
assetsPath: staticBaseUrl + 'conversejs/',
isRemoteChat: !!(roomInfos.video?.remote),
localAnonymousJID: localAnonymousJID,
localAnonymousJID: !settings['chat-no-anonymous'] ? localAnonymousJID : null,
remoteAnonymousJID: remoteConnectionInfos?.anonymous?.userJID ?? null,
remoteAnonymousXMPPServer: !!(remoteConnectionInfos?.anonymous),
remoteAuthenticatedXMPPServer: !!(remoteConnectionInfos?.authenticated),

View File

@ -2,7 +2,7 @@ type ConverseJSTheme = 'peertube' | 'default' | 'concord'
interface InitConverseJSParams {
isRemoteChat: boolean
localAnonymousJID: string
localAnonymousJID: string | null
remoteAnonymousJID: string | null
remoteAnonymousXMPPServer: boolean
remoteAuthenticatedXMPPServer: boolean