]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/develop' into 1701-poco
authorMichael <heluecht@pirati.ca>
Sun, 19 Mar 2017 15:36:41 +0000 (15:36 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 19 Mar 2017 15:36:41 +0000 (15:36 +0000)
Conflicts:
include/socgraph.php

1  2 
include/socgraph.php

index ac8068b4d7a17d9f73eed4d094a1e9a88de6229d,d9fd6f8be8a04db27482cf19a3180cb7b398f8b4..67f9e8aa60bfc2a3f0795a36ba73accc64af3056
@@@ -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"]) {