diff --git a/conversejs/builtin.ts b/conversejs/builtin.ts index dd58f2fd..9b4919d2 100644 --- a/conversejs/builtin.ts +++ b/conversejs/builtin.ts @@ -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 = '

This chatroom does not exist, or is not accessible to you.

' + return + } else { + throw new Error('Can\'t connect, no JID') } } diff --git a/server/lib/conversejs/params.ts b/server/lib/conversejs/params.ts index ed48595d..16cb850c 100644 --- a/server/lib/conversejs/params.ts +++ b/server/lib/conversejs/params.ts @@ -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), diff --git a/shared/lib/types.ts b/shared/lib/types.ts index 3cd72591..1b94be23 100644 --- a/shared/lib/types.ts +++ b/shared/lib/types.ts @@ -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