From f50457f7d55faaaed8bf46baa1fb1c0bd67fe098 Mon Sep 17 00:00:00 2001 From: gravel Date: Wed, 12 Apr 2023 14:46:20 +0000 Subject: [PATCH] Clarify merging logic --- php/utils/servers-rooms.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/php/utils/servers-rooms.php b/php/utils/servers-rooms.php index c535237..20e7cde 100644 --- a/php/utils/servers-rooms.php +++ b/php/utils/servers-rooms.php @@ -204,20 +204,23 @@ * @param CommunityServer $server */ private function merge_from($server) { + // Merge room hint information. $this->room_hints = [ ...$this->room_hints, ...$server->room_hints ]; + // Merge public key information. if (!$this->has_pubkey() && $server->has_pubkey()) { $this->pubkey = $server->pubkey; } + // Prefer HTTPS URLs over HTTP. if (str_starts_with($server->base_url, "https:")) { $this->base_url = $server->get_scheme() . "://" . $this->get_hostname(); } - // Overwrite IPs + // Prefer domain names over IPs (connections to SOGS survive relocation). if (filter_var($this->get_hostname(), FILTER_VALIDATE_IP)) { $this->base_url = $this->get_scheme() . "://" . $server->get_hostname(); } @@ -227,6 +230,7 @@ * Re-introduces the server to a consistent state after merging. */ private function merge_consistency() { + // Remove duplicate room hints; does not require sorting. $this->room_hints = array_unique($this->room_hints); }