Print port in serve-local script
This commit is contained in:
parent
4bc70d99f4
commit
7d2dd5cc68
@ -56,6 +56,17 @@ export class HomeServer {
|
|||||||
return body;
|
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) {
|
async findPublicRoomById(roomId) {
|
||||||
const {body, status} = await this._request(`${this.baseURL}/_matrix/client/r0/directory/list/room/${encodeURIComponent(roomId)}`).response();
|
const {body, status} = await this._request(`${this.baseURL}/_matrix/client/r0/directory/list/room/${encodeURIComponent(roomId)}`).response();
|
||||||
if (status !== 200 || body.visibility !== "public") {
|
if (status !== 200 || body.visibility !== "public") {
|
||||||
|
@ -88,6 +88,11 @@ export class PreviewViewModel extends ViewModel {
|
|||||||
|
|
||||||
async _loadRoomPreview(homeserver, link) {
|
async _loadRoomPreview(homeserver, link) {
|
||||||
let publicRoom;
|
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) {
|
if (link.identifierKind === IdentifierKind.RoomId) {
|
||||||
publicRoom = await homeserver.findPublicRoomById(link.identifier);
|
publicRoom = await homeserver.findPublicRoomById(link.identifier);
|
||||||
} else if (link.identifierKind === IdentifierKind.RoomAlias) {
|
} else if (link.identifierKind === IdentifierKind.RoomAlias) {
|
||||||
@ -96,6 +101,8 @@ export class PreviewViewModel extends ViewModel {
|
|||||||
publicRoom = await homeserver.findPublicRoomById(roomId);
|
publicRoom = await homeserver.findPublicRoomById(roomId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.name = publicRoom?.name || publicRoom?.canonical_alias || link.identifier;
|
this.name = publicRoom?.name || publicRoom?.canonical_alias || link.identifier;
|
||||||
this.avatarUrl = publicRoom?.avatar_url ?
|
this.avatarUrl = publicRoom?.avatar_url ?
|
||||||
homeserver.mxcUrlThumbnail(publicRoom.avatar_url, 64, 64, "crop") :
|
homeserver.mxcUrlThumbnail(publicRoom.avatar_url, 64, 64, "crop") :
|
||||||
|
Loading…
Reference in New Issue
Block a user