diff --git a/package.json b/package.json index bd931ed7..9a025817 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,6 @@ "config": "^3.3.1", "escape-html": "^1.0.3", "js-yaml": "^3.13.1", - "matrix-bot-sdk": "^0.5.3" + "matrix-bot-sdk": "^0.5.4" } } diff --git a/src/utils.ts b/src/utils.ts index edff319c..75dfd74a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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 { - 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 - } -} diff --git a/yarn.lock b/yarn.lock index 6656033c..de734d14 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1704,10 +1704,10 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" -matrix-bot-sdk@^0.5.3: - version "0.5.3" - resolved "https://registry.yarnpkg.com/matrix-bot-sdk/-/matrix-bot-sdk-0.5.3.tgz#ec01a76a9ec9d120cee4461dda3b0db01e8a32de" - integrity sha512-jmoU55HbJpvTopZrjMca5u7jmfW3j/Fc3vPExs+5RRqFNCChT/TYQxr7PXD9Ho96YbL7zJ3zynOZ3fXvHg4hYA== +matrix-bot-sdk@^0.5.4: + version "0.5.4" + resolved "https://registry.yarnpkg.com/matrix-bot-sdk/-/matrix-bot-sdk-0.5.4.tgz#8c26bef826bd0b3fc9b693c8d07b52c30d843fd7" + integrity sha512-nUAE1WW7ast+Xsfux1+qBPmKSY6OG0RoZfeh0WfMP42JW6GRnNiY3hq7aiifomnJAMASZ6EwkdHS3ChWpIRYzg== dependencies: "@types/express" "^4.17.2" chalk "^3.0.0"