From: Michael Date: Sun, 19 Mar 2017 15:36:41 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/develop' into 1701-poco X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7f61b2ee151470a34c9a3846e2388c75d73f9460;p=friendica.git Merge remote-tracking branch 'upstream/develop' into 1701-poco Conflicts: include/socgraph.php --- 7f61b2ee151470a34c9a3846e2388c75d73f9460 diff --cc include/socgraph.php index ac8068b4d7,d9fd6f8be8..67f9e8aa60 --- a/include/socgraph.php +++ b/include/socgraph.php @@@ -1281,44 -1668,37 +1668,47 @@@ function poco_discover_federation() set_config('poco','last_federation_discovery', time()); } -function poco_discover($complete = false) { +function poco_discover_single_server($id) { + $r = q("SELECT `poco`, `nurl`, `url`, `network` FROM `gserver` WHERE `id` = %d", intval($id)); + if (!dbm::is_result($r)) { + return false; + } - // Update the server list - poco_discover_federation(); + $server = $r[0]; - $no_of_queries = 5; + if (!poco_check_server($server["url"], $server["network"])) { + // The server is not reachable? Okay, then we will try it later + q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(datetime_convert()), dbesc($server["nurl"])); + return false; + } - $requery_days = intval(get_config("system", "poco_requery_days")); ++ // Discover new servers out there ++ poco_fetch_serverlist($server["poco"]); + - if ($requery_days == 0) - $requery_days = 7; + // Fetch all users from the other server + $url = $server["poco"]."/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation"; - $last_update = date("c", time() - (60 * 60 * 24 * $requery_days)); + logger("Fetch all users from the server ".$server["nurl"], LOGGER_DEBUG); - $r = q("SELECT `poco`, `nurl`, `url`, `network` FROM `gserver` WHERE `last_contact` >= `last_failure` AND `poco` != '' AND `last_poco_query` < '%s' ORDER BY RAND()", dbesc($last_update)); - if ($r) - foreach ($r AS $server) { + $retdata = z_fetch_url($url); + if ($retdata["success"]) { + $data = json_decode($retdata["body"]); + + poco_discover_server($data, 2); + + if (get_config('system','poco_discovery') > 1) { - if (!poco_check_server($server["url"], $server["network"])) { - // The server is not reachable? Okay, then we will try it later - q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(datetime_convert()), dbesc($server["nurl"])); - continue; + $timeframe = get_config('system','poco_discovery_since'); + if ($timeframe == 0) { + $timeframe = 30; } - // Discover new servers out there - poco_fetch_serverlist($server["poco"]); + $updatedSince = date("Y-m-d H:i:s", time() - $timeframe * 86400); - // Fetch all users from the other server - $url = $server["poco"]."/?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation"; + // Fetch all global contacts from the other server (Not working with Redmatrix and Friendica versions before 3.3) + $url = $server["poco"]."/@global?updatedSince=".$updatedSince."&fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation"; - logger("Fetch all users from the server ".$server["nurl"], LOGGER_DEBUG); + $success = false; $retdata = z_fetch_url($url); if ($retdata["success"]) {