X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FDiaspora.php;h=d578ba4545264085a265dd6ac3f574d721547707;hb=ce7ec11d1d40b21c68086962791f985d407f1cd1;hp=18dcd759a1053c3742f992f93fce25b20631df0f;hpb=1d8b80922795c35c36e10f3415310a9ef04dd9cd;p=friendica.git diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 18dcd759a1..d578ba4545 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -223,7 +223,7 @@ class Diaspora `fcontact`.`batch` AS `fbatch`, `fcontact`.`network` AS `fnetwork` FROM `participation` INNER JOIN `contact` ON `contact`.`id` = `participation`.`cid` INNER JOIN `fcontact` ON `fcontact`.`id` = `participation`.`fid` - WHERE `participation`.`iid` = ?", $thread); + WHERE `participation`.`iid` = ? AND NOT `contact`.`archive`", $thread); while ($contact = DBA::fetch($r)) { if (!empty($contact['fnetwork'])) { @@ -942,31 +942,41 @@ class Diaspora * @brief Fetches data for a given handle * * @param string $handle The handle + * @param boolean $update true = always update, false = never update, null = update when not found or outdated * * @return array the queried data * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ - public static function personByHandle($handle) + public static function personByHandle($handle, $update = null) { - $update = false; - $person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]); + if (!DBA::isResult($person)) { + $urls = [$handle, str_replace('http://', 'https://', $handle), Strings::normaliseLink($handle)]; + $person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'url' => $urls]); + } + if (DBA::isResult($person)) { Logger::debug("In cache " . print_r($person, true)); - // update record occasionally so it doesn't get stale - $d = strtotime($person["updated"]." +00:00"); - if ($d < strtotime("now - 14 days")) { - $update = true; - } + if (is_null($update)) { + // update record occasionally so it doesn't get stale + $d = strtotime($person["updated"]." +00:00"); + if ($d < strtotime("now - 14 days")) { + $update = true; + } - if ($person["guid"] == "") { - $update = true; + if ($person["guid"] == "") { + $update = true; + } } + } elseif (is_null($update)) { + $update = !DBA::isResult($person); + } else { + $person = []; } - if (!DBA::isResult($person) || $update) { + if ($update) { Logger::log("create or refresh", Logger::DEBUG); $r = Probe::uri($handle, Protocol::DIASPORA); @@ -975,12 +985,7 @@ class Diaspora if ($r && ($r["network"] === Protocol::DIASPORA)) { self::updateFContact($r); - // Fetch the updated or added contact - $person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]); - if (!DBA::isResult($person)) { - $person = $r; - $person['id'] = 0; - } + $person = self::personByHandle($handle, false); } } @@ -1117,6 +1122,20 @@ class Diaspora return $contact; } + /** + * Checks if the given contact url does support ActivityPub + * + * @param string $url profile url + * @param boolean $update true = always update, false = never update, null = update when not found or outdated + * @return boolean + * @throws \Friendica\Network\HTTPException\InternalServerErrorException + * @throws \ImagickException + */ + public static function isSupportedByContactUrl($url, $update = null) + { + return !empty(self::personByHandle($url, $update)); + } + /** * @brief Check if posting is allowed for this contact *