Fix room creation
The room alias is not part of the spec. Synapse returns it anyway, but it's not part of the js-sdk types. We don't really need the server to tell us what the alias is, so just generate it locally instead.
This commit is contained in:
@@ -108,7 +108,7 @@ export async function initClient(
|
||||
return client;
|
||||
}
|
||||
|
||||
export function roomAliasFromRoomName(roomName: string): string {
|
||||
export function roomAliasLocalpartFromRoomName(roomName: string): string {
|
||||
return roomName
|
||||
.trim()
|
||||
.replace(/\s/g, "-")
|
||||
@@ -116,6 +116,13 @@ export function roomAliasFromRoomName(roomName: string): string {
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
export function fullAliasFromRoomName(
|
||||
roomName: string,
|
||||
client: MatrixClient
|
||||
): string {
|
||||
return `#${roomAliasLocalpartFromRoomName(roomName)}:${client.getDomain()}`;
|
||||
}
|
||||
|
||||
export function roomNameFromRoomId(roomId: string): string {
|
||||
return roomId
|
||||
.match(/([^:]+):.*$/)[1]
|
||||
@@ -151,7 +158,7 @@ export async function createRoom(
|
||||
visibility: Visibility.Private,
|
||||
preset: Preset.PublicChat,
|
||||
name,
|
||||
room_alias_name: roomAliasFromRoomName(name),
|
||||
room_alias_name: roomAliasLocalpartFromRoomName(name),
|
||||
power_level_content_override: {
|
||||
invite: 100,
|
||||
kick: 100,
|
||||
@@ -177,7 +184,7 @@ export async function createRoom(
|
||||
},
|
||||
});
|
||||
|
||||
console.log({ isPtt });
|
||||
console.log(`Creating ${isPtt ? "PTT" : "video"} group call room`);
|
||||
|
||||
await client.createGroupCall(
|
||||
createRoomResult.room_id,
|
||||
@@ -186,7 +193,7 @@ export async function createRoom(
|
||||
GroupCallIntent.Prompt
|
||||
);
|
||||
|
||||
return createRoomResult.room_id;
|
||||
return fullAliasFromRoomName(name, client);
|
||||
}
|
||||
|
||||
export function getRoomUrl(roomId: string): string {
|
||||
|
||||
Reference in New Issue
Block a user