Print port in serve-local script
This commit is contained in:
parent
4bc70d99f4
commit
7d2dd5cc68
2 changed files with 26 additions and 8 deletions
|
@ -56,6 +56,17 @@ export class HomeServer {
|
|||
return body;
|
||||
}
|
||||
|
||||
// MSC3266 implementation
|
||||
async getRoomSummary(roomIdOrAlias, viaServers) {
|
||||
let query;
|
||||
if (viaServers.length > 0) {
|
||||
query = "?" + viaServers.map(server => `via=${encodeURIComponent(server)}`).join('&');
|
||||
}
|
||||
const {body, status} = await this._request(`${this.baseURL}/_matrix/client/unstable/im.nheko.summary/rooms/${encodeURIComponent(roomIdOrAlias)}/summary${query}`).response();
|
||||
if (status !== 200) return;
|
||||
return body;
|
||||
}
|
||||
|
||||
async findPublicRoomById(roomId) {
|
||||
const {body, status} = await this._request(`${this.baseURL}/_matrix/client/r0/directory/list/room/${encodeURIComponent(roomId)}`).response();
|
||||
if (status !== 200 || body.visibility !== "public") {
|
||||
|
|
|
@ -88,6 +88,11 @@ export class PreviewViewModel extends ViewModel {
|
|||
|
||||
async _loadRoomPreview(homeserver, link) {
|
||||
let publicRoom;
|
||||
if (link.identifierKind === IdentifierKind.RoomId || link.identifierKind === IdentifierKind.RoomAlias) {
|
||||
publicRoom = await homeserver.getRoomSummary(link.identifier, link.servers);
|
||||
}
|
||||
|
||||
if (!publicRoom) {
|
||||
if (link.identifierKind === IdentifierKind.RoomId) {
|
||||
publicRoom = await homeserver.findPublicRoomById(link.identifier);
|
||||
} else if (link.identifierKind === IdentifierKind.RoomAlias) {
|
||||
|
@ -96,6 +101,8 @@ export class PreviewViewModel extends ViewModel {
|
|||
publicRoom = await homeserver.findPublicRoomById(roomId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.name = publicRoom?.name || publicRoom?.canonical_alias || link.identifier;
|
||||
this.avatarUrl = publicRoom?.avatar_url ?
|
||||
homeserver.mxcUrlThumbnail(publicRoom.avatar_url, 64, 64, "crop") :
|
||||
|
|
Loading…
Reference in a new issue