get_join_urls()); // Add known hosts. $servers = [...CommunityServer::from_known_hosts($KNOWN_SERVERS, $KNOWN_PUBKEYS), ...$servers]; // Merge servers with the same URL. $servers = CommunityServer::dedupe_by_url($servers); // Fetch server data and filter unreachable servers. $servers = CommunityServer::poll_reachable($servers); // Merge servers with the same public key. $servers = CommunityServer::dedupe_by_pubkey($servers); // Fill additional information from sources. CommunityServer::source_additional_info($servers, $sources); // Count servers and rooms. $servers_total = count($servers); $rooms_total = count_rooms($servers); log_info("Done fetching communities."); log_info( "Found $rooms_total unique Session Communities " . "on $servers_total servers." . PHP_EOL ); // Output fetching results to file. file_put_contents($ROOMS_FILE, json_encode($servers)); } /** * Debug function to see which communities use pinned messages already * @deprecated */ function print_pinned_messages($room_assignments_arr) { // for each server a.k.a. public key do foreach($room_assignments_arr as $pubkey => $room_assignment) { // for every room do foreach($room_assignment[1] as $room_array) { // info: // $room_array = array( // "token" => bla, // "name" => Blabla, // "active_users" => -1, // "description" => Blabla bla bla //); $server_url = $room_assignment[0]; $room_json_url = $server_url . "/room/" . $room_array["token"]; echo($room_json_url . PHP_EOL); $contents = file_get_contents($room_json_url); if($contents) { // print_r($contents); $json_obj = json_decode($contents); $pinned_messages = $json_obj->pinned_messages; echo("Pinned messages:" . PHP_EOL); print_r($pinned_messages); } } } } // Fetch servers main(); ?>