From 4b1f9a4b712f50c08a05933177f830376a0dceb1 Mon Sep 17 00:00:00 2001 From: Timo Date: Fri, 21 Jun 2024 11:24:09 +0200 Subject: [PATCH] Add try inner try block to the room summary fetching and only throw after fetching and a "blind join" fails. (blind join: call room.join without knowing if the room is public) --- src/room/useLoadGroupCall.ts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/room/useLoadGroupCall.ts b/src/room/useLoadGroupCall.ts index d9a3d7ed..96e38535 100644 --- a/src/room/useLoadGroupCall.ts +++ b/src/room/useLoadGroupCall.ts @@ -225,9 +225,27 @@ export const useLoadGroupCall = ( }); } else { // If the room does not exist we first search for it with viaServers - const roomSummary = await client.getRoomSummary(roomId, viaServers); - if (roomSummary.join_rule === JoinRule.Public) { - room = await client.joinRoom(roomSummary.room_id, { + let roomSummary: RoomSummary | undefined = undefined; + try { + roomSummary = await client.getRoomSummary(roomId, viaServers); + } catch (error) { + // If the room summary endpoint is not supported we let it be undefined and treat this case like + // `JoinRule.Public`. + // This is how the logic was done before: "we expect any room id passed to EC + // to be for a public call" Which is definitely not ideal but worth a try if fetching + // the summary crashes. + logger.error( + `Could not load room summary to decide whether we want to join or knock. + EC will fallback to join as if this would be a public room. + Reach out to your homeserver admin to ask them about supporting the \`/summary\` endpoint (im.nheko.summary):`, + error, + ); + } + if ( + roomSummary?.join_rule === JoinRule.Public || + roomSummary === undefined + ) { + room = await client.joinRoom(roomId, { viaServers, }); } else if (roomSummary.join_rule === JoinRule.Knock) {