| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -664,8 +664,10 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						 * @return array|false Associative data about rooms if successful.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						 */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						private function fetch_room_list(): array|bool {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							global $FAST_FETCH_MODE;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							$base_url = $this->base_url;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							list($rooms, $downgrade) = curl_get_contents_downgrade("$base_url/rooms?all=1");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							list($rooms, $downgrade) = curl_get_contents_downgrade("$base_url/rooms?all=1", retries: $FAST_FETCH_MODE ? 2 : 4);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (!$rooms) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								log_info("Failed fetching /rooms.");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								return false;
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -726,6 +728,8 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						 * @return bool True if successful, false otherwise.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						 */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						function fetch_rooms(): bool {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							global $FAST_FETCH_MODE;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							$this->log_details();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							$base_url = $this->base_url;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -733,7 +737,7 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (count($this->room_hints) >= 2) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								log_info("Checking reachability for $base_url first...");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								log_value($this->room_hints);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								if (!url_is_reachable($base_url)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								if (!url_is_reachable($base_url, retries: $FAST_FETCH_MODE ? 1 : 4)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									log_warning("Reachability test failed by $base_url.");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									return false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								}
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -757,6 +761,8 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						 * @return bool True iff no key conflict has arised and we have a pubkey.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						 */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						function fetch_pubkey() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							global $FAST_FETCH_MODE;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (empty($this->rooms)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								log_warning("Server has no rooms to poll for public key");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								return false;
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -764,10 +770,14 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							$has_pubkey = $this->has_pubkey();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if ($has_pubkey && $FAST_FETCH_MODE) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								return true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							$preview_url = $this->rooms[0]->get_preview_url();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							log_info("Fetching pubkey from $preview_url");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							$room_view = curl_get_contents($preview_url, retries: $has_pubkey ? 1 : 5);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							$room_view = curl_get_contents($preview_url, retries: $has_pubkey || $FAST_FETCH_MODE ? 1 : 5);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (!$room_view) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								log_debug("Failed to fetch room preview from $preview_url.");
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |