fix: prefer expected join link for pubkey

dev
gravel 2 years ago
parent 014722a559
commit 55c7a8b494
Signed by: gravel
GPG Key ID: C0538F3C906B308F

@ -353,13 +353,22 @@
return "$base_url/r/$token/invite.png";
}
/**
* Return a string used to match the in-app join URL for this room.
*/
function _get_join_url_match(): string {
$hostname = $this->server->get_hostname(include_port: true);
$token = $this->token;
return "$hostname/$token?public_key=";
}
/**
* Return the in-app join URL for this room.
*/
function get_join_url(): string {
$base_url = $this->server->base_url;
$pubkey = $this->server->get_pubkey();
$token = $this->token;
$pubkey = $this->server->get_pubkey();
return "$base_url/$token?public_key=$pubkey";
}
@ -1351,10 +1360,12 @@
}
// This is ugly. 'RoomBuilder' would be better.
$preview_url = CommunityRoom::_from_intermediate_data(
$room_intermediate = CommunityRoom::_from_intermediate_data(
$this,
$this->_intermediate_room_data[0]
)->get_preview_url();
);
$preview_url = $room_intermediate->get_preview_url();
log_info("Fetching pubkey from $preview_url");
$room_view_response = yield from FetchingCoroutine
@ -1372,7 +1383,11 @@
}
$links = parse_join_links($room_view);
$link = $links[0];
$join_link_part = $room_intermediate->_get_join_url_match();
$link = array_values(array_filter($links, function (string $link) use ($join_link_part) {
return str_contains($link, $join_link_part);
}))[0] ?? $links[0];
if (!isset($link)) {
log_debug("Could not locate join link in preview at $preview_url.");

Loading…
Cancel
Save