]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/APContact.php
Preparations for "featured" posts
[friendica.git] / src / Model / APContact.php
index 5e992075e8d3c8999dcb1f22b67fadf2f30fa8e6..e068ecefe2b9d534c6c10c5639f27cee90ddfab0 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -28,6 +28,7 @@ use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Database\DBStructure;
 use Friendica\DI;
+use Friendica\Network\HTTPClient\Client\HttpClient;
 use Friendica\Network\HTTPException;
 use Friendica\Network\Probe;
 use Friendica\Protocol\ActivityNamespace;
@@ -38,7 +39,6 @@ use Friendica\Util\DateTimeFormat;
 use Friendica\Util\HTTPSignature;
 use Friendica\Util\JsonLD;
 use Friendica\Util\Network;
-use Friendica\Util\Strings;
 
 class APContact
 {
@@ -71,10 +71,10 @@ class APContact
 
                $data = ['addr' => $addr];
                $template = 'https://' . $addr_parts[1] . '/.well-known/webfinger?resource=acct:' . urlencode($addr);
-               $webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), 'application/jrd+json');
+               $webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), HttpClient::ACCEPT_JRD_JSON);
                if (empty($webfinger['links'])) {
                        $template = 'http://' . $addr_parts[1] . '/.well-known/webfinger?resource=acct:' . urlencode($addr);
-                       $webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), 'application/jrd+json');
+                       $webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), HttpClient::ACCEPT_JRD_JSON);
                        if (empty($webfinger['links'])) {
                                return [];
                        }
@@ -168,7 +168,7 @@ class APContact
 
                // Detect multiple fast repeating request to the same address
                // See https://github.com/friendica/friendica/issues/9303
-               $cachekey = 'apcontact:getByURL:' . $url;
+               $cachekey = 'apcontact:' . ItemURI::getIdByURI($url);
                $result = DI::cache()->get($cachekey);
                if (!is_null($result)) {
                        Logger::notice('Multiple requests for the address', ['url' => $url, 'update' => $update, 'callstack' => System::callstack(20), 'result' => $result]);
@@ -231,6 +231,9 @@ class APContact
                        self::unarchiveInbox($apcontact['sharedinbox'], true);
                }
 
+               $apcontact['featured']      = JsonLD::fetchElement($compacted, 'toot:featured', '@id');
+               $apcontact['featured-tags'] = JsonLD::fetchElement($compacted, 'toot:featuredTags', '@id');
+
                $apcontact['nick'] = JsonLD::fetchElement($compacted, 'as:preferredUsername', '@value') ?? '';
                $apcontact['name'] = JsonLD::fetchElement($compacted, 'as:name', '@value');