feat: enhance room data retrieval with server domain extraction

This commit is contained in:
2026-02-21 22:21:56 +11:00
parent ef55d1583f
commit f00e20b1ac
2 changed files with 67 additions and 10 deletions

View File

@@ -305,12 +305,19 @@ async function getChannels(matrixClient: any) {
return rooms
.filter((room: any) => !room.isSpaceRoom())
.map((room: any) => ({
roomId: room.roomId,
name: room.name || 'Unnamed Room',
isDirect: room.getMyMembership() === 'invite' ? false : room.guessDMUserId() !== null,
avatar: room.getMxcAvatarUrl() || null,
}))
.map((room: any) => {
// Extract server domain from roomId (!localpart:domain.tld)
const serverMatch = room.roomId.match(/:(.+)$/);
const server = serverMatch ? serverMatch[1] : null;
return {
roomId: room.roomId,
name: room.name || 'Unnamed Room',
server: server,
isDirect: room.getMyMembership() === 'invite' ? false : room.guessDMUserId() !== null,
avatar: room.getMxcAvatarUrl() || null,
};
})
.sort((a: any, b: any) => a.name.localeCompare(b.name));
}
@@ -362,9 +369,14 @@ async function getCurrentRoom(matrixClient: any) {
throw new Error(`Current room not found: ${currentRoomId}`);
}
// Extract server domain from roomId (!localpart:domain.tld)
const serverMatch = room.roomId.match(/:(.+)$/);
const server = serverMatch ? serverMatch[1] : null;
return {
roomId: room.roomId,
name: room.name || 'Unnamed Room',
server: server,
avatar: room.getMxcAvatarUrl() || null,
isDirect: room.guessDMUserId() !== null,
};