feat: enhance room data retrieval with server domain extraction
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user