X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FGlobalContact.php;h=6ec1101775df0f636f838a7e6c29499fce4166ce;hb=b0dcfc2724188c309a70ce5281e94fdf6a733498;hp=dc62024bc4095120ca6f24aa11bb33bdc6c100bc;hpb=47db624105182194b11f0039742deda6fc12c54d;p=friendica.git diff --git a/src/Model/GlobalContact.php b/src/Model/GlobalContact.php index dc62024bc4..6ec1101775 100644 --- a/src/Model/GlobalContact.php +++ b/src/Model/GlobalContact.php @@ -1,5 +1,4 @@ entries) { foreach ($j->entries as $entry) { - poco_check_server($entry->url); + PortableContact::checkServer($entry->url); $url = $entry->url . '/poco'; if (! in_array($url, $done)) { @@ -588,10 +636,11 @@ class GlobalContact * @brief Replace alternate OStatus user format with the primary one * * @param arr $contact contact array (called by reference) + * @return void */ public static function fixAlternateContactAddress(&$contact) { - if (($contact["network"] == NETWORK_OSTATUS) && poco_alternate_ostatus_url($contact["url"])) { + if (($contact["network"] == NETWORK_OSTATUS) && PortableContact::alternateOStatusUrl($contact["url"])) { $data = Probe::uri($contact["url"]); if ($contact["network"] == NETWORK_OSTATUS) { logger("Fix primary url from ".$contact["url"]." to ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); @@ -688,7 +737,7 @@ class GlobalContact if ($doprobing) { logger("Last Contact: ". $last_contact_str." - Last Failure: ".$last_failure_str." - Checking: ".$contact["url"], LOGGER_DEBUG); - Worker::add(PRIORITY_LOW, 'gprobe', $contact["url"]); + Worker::add(PRIORITY_LOW, 'GProbe', $contact["url"]); } return $gcontact_id; @@ -832,7 +881,7 @@ class GlobalContact if (DBM::is_result($r)) { logger("Update public contact ".$r[0]["id"], LOGGER_DEBUG); - update_contact_avatar($contact["photo"], 0, $r[0]["id"]); + Contact::updateAvatar($contact["photo"], 0, $r[0]["id"]); $fields = array('name', 'nick', 'addr', 'network', 'bd', 'gender', @@ -859,6 +908,7 @@ class GlobalContact * @brief Updates the gcontact entry from probe * * @param str $url profile link + * @return void */ public static function updateFromProbe($url) { @@ -878,6 +928,7 @@ class GlobalContact * @brief Update the gcontact entry for a given user id * * @param int $uid User ID + * @return void */ public static function updateForUser($uid) { @@ -894,7 +945,7 @@ class GlobalContact intval($uid) ); - $location = formatted_location( + $location = Profile::formatLocation( array("locality" => $r[0]["locality"], "region" => $r[0]["region"], "country-name" => $r[0]["country-name"]) ); @@ -923,8 +974,9 @@ class GlobalContact * If the "Statistics" plugin is enabled (See http://gstools.org/ for details) we query user data with this. * * @param str $server Server address + * @return void */ - public static function gsFetchUsers($server) + public static function fetchGsUsers($server) { logger("Fetching users from GNU Social server ".$server, LOGGER_DEBUG); @@ -978,9 +1030,9 @@ class GlobalContact /** * @brief Asking GNU Social server on a regular base for their user data - * + * @return void */ - public static function gsDiscover() + public static function discoverGsUsers() { $requery_days = intval(Config::get("system", "poco_requery_days")); @@ -997,8 +1049,28 @@ class GlobalContact } foreach ($r as $server) { - self::gsFetchUsers($server["url"]); + self::fetchGsUsers($server["url"]); q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(datetime_convert()), dbesc($server["nurl"])); } } + + /** + * @return string + */ + public static function getRandomUrl() + { + $r = q( + "SELECT `url` FROM `gcontact` WHERE `network` = '%s' + AND `last_contact` >= `last_failure` + AND `updated` > UTC_TIMESTAMP - INTERVAL 1 MONTH + ORDER BY rand() LIMIT 1", + dbesc(NETWORK_DFRN) + ); + + if (DBM::is_result($r)) { + return dirname($r[0]['url']); + } + + return ''; + } }