]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/APContact.php
Merge pull request #12674 from nupplaphil/bug/config_typesafe
[friendica.git] / src / Model / APContact.php
index fd748f1cd4e92419b77513f5cad205a3cec60fcb..09a6cb9e78db781f1ccabac557cd5fbc0747b40c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -226,14 +226,11 @@ class APContact
                $apcontact['following'] = JsonLD::fetchElement($compacted, 'as:following', '@id');
                $apcontact['followers'] = JsonLD::fetchElement($compacted, 'as:followers', '@id');
                $apcontact['inbox'] = (JsonLD::fetchElement($compacted, 'ldp:inbox', '@id') ?? '');
-               self::unarchiveInbox($apcontact['inbox'], false);
-
                $apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id');
 
                $apcontact['sharedinbox'] = '';
                if (!empty($compacted['as:endpoints'])) {
                        $apcontact['sharedinbox'] = (JsonLD::fetchElement($compacted['as:endpoints'], 'as:sharedInbox', '@id') ?? '');
-                       self::unarchiveInbox($apcontact['sharedinbox'], true);
                }
 
                $apcontact['featured']      = JsonLD::fetchElement($compacted, 'toot:featured', '@id');
@@ -427,6 +424,12 @@ class APContact
                        $apcontact['gsid'] = null;
                }
 
+               self::unarchiveInbox($apcontact['inbox'], false, $apcontact['gsid']);
+
+               if (!empty($apcontact['sharedinbox'])) {
+                       self::unarchiveInbox($apcontact['sharedinbox'], true, $apcontact['gsid']);
+               }
+
                if ($apcontact['url'] == $apcontact['alias']) {
                        $apcontact['alias'] = null;
                }
@@ -517,7 +520,7 @@ class APContact
        {
                if (!empty($apcontact['inbox'])) {
                        Logger::info('Set inbox status to failure', ['inbox' => $apcontact['inbox']]);
-                       HTTPSignature::setInboxStatus($apcontact['inbox'], false);
+                       HTTPSignature::setInboxStatus($apcontact['inbox'], false, false, $apcontact['gsid']);
                }
 
                if (!empty($apcontact['sharedinbox'])) {
@@ -527,7 +530,7 @@ class APContact
                        if (!$available) {
                                // If all known personal inboxes are failing then set their shared inbox to failure as well
                                Logger::info('Set shared inbox status to failure', ['sharedinbox' => $apcontact['sharedinbox']]);
-                               HTTPSignature::setInboxStatus($apcontact['sharedinbox'], false, true);
+                               HTTPSignature::setInboxStatus($apcontact['sharedinbox'], false, true, $apcontact['gsid']);
                        }
                }
        }
@@ -542,11 +545,11 @@ class APContact
        {
                if (!empty($apcontact['inbox'])) {
                        Logger::info('Set inbox status to success', ['inbox' => $apcontact['inbox']]);
-                       HTTPSignature::setInboxStatus($apcontact['inbox'], true);
+                       HTTPSignature::setInboxStatus($apcontact['inbox'], true, false, $apcontact['gsid']);
                }
                if (!empty($apcontact['sharedinbox'])) {
                        Logger::info('Set shared inbox status to success', ['sharedinbox' => $apcontact['sharedinbox']]);
-                       HTTPSignature::setInboxStatus($apcontact['sharedinbox'], true, true);
+                       HTTPSignature::setInboxStatus($apcontact['sharedinbox'], true, true, $apcontact['gsid']);
                }
        }
 
@@ -555,15 +558,16 @@ class APContact
         *
         * @param string  $url    inbox url
         * @param boolean $shared Shared Inbox
+        * @param int     $gsid   Global server id
         * @return void
         */
-       private static function unarchiveInbox(string $url, bool $shared)
+       private static function unarchiveInbox(string $url, bool $shared, int $gsid = null)
        {
                if (empty($url)) {
                        return;
                }
 
-               HTTPSignature::setInboxStatus($url, true, $shared);
+               HTTPSignature::setInboxStatus($url, true, $shared, $gsid);
        }
 
        /**