mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-10-23 01:21:16 +00:00
Bump bot-sdk version to handle published aliases better
This commit is contained in:
1 parent
9e18a6dfff
commit
46bc6a1a0f
3 files changed
+6
-21
No files matched your search
+1
-16
@@ -187,7 +187,7 @@ export async function replaceRoomIdsWithPills(client: MatrixClient, text: string
|
||||
for (const roomId of roomIds) {
|
||||
let alias = roomId;
|
||||
try {
|
||||
alias = (await getRoomAlias(client, roomId)) || roomId;
|
||||
alias = (await client.getPublishedAlias(roomId)) || roomId;
|
||||
} catch (e) {
|
||||
// This is a recursive call, so tell the function not to try and call us
|
||||
await logMessage(LogLevel.WARN, "utils", `Failed to resolve room alias for ${roomId} - see console for details`, null, true);
|
||||
@@ -200,18 +200,3 @@ export async function replaceRoomIdsWithPills(client: MatrixClient, text: string
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
// TODO: Merge this function into js-bot-sdk
|
||||
export async function getRoomAlias(client: MatrixClient, roomId: string): Promise<string> {
|
||||
try {
|
||||
const event = await client.getRoomStateEvent(roomId, "m.room.canonical_alias", "");
|
||||
if (!event) return null;
|
||||
|
||||
const canonical = event['alias'];
|
||||
const alt = event['alt_aliases'] || [];
|
||||
|
||||
return canonical || alt[0];
|
||||
} catch (e) {
|
||||
return null; // assume none
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user