| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -26,15 +26,20 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					function room_qr_code($room): string {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						$room_id = $room->get_room_identifier();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						$png_cached = room_qr_code_path($room_id);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (file_exists($png_cached)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						$image_expired = file_exists($png_cached) && 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							filemtime($png_cached) < strtotime("-12 hour");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (file_exists($png_cached) && !$image_expired) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return room_qr_code_path_relative($room_id);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						log_debug("Fetching QR code for $room_id.");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						$png = file_get_contents($room->get_invite_url());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (empty($png)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							log_warning("$room_id returned empty QR code.");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							log_warning("$room_id returned an empty QR code.");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						// Never overwrite with an empty file.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (!(file_exists($png_cached) && filesize($png_cached) > 0 && empty($png))) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							file_put_contents($png_cached, $png);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						file_put_contents($png_cached, $png);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return room_qr_code_path_relative($room_id);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |