X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FAPContact.php;h=7a63e413cab3ee5f6f26d6ad8c5b8acfe1c4a629;hb=a24febb8b656217a7cd88db205007420cb64485e;hp=37faf240ce1bc5efcf22826e7a4b5ba1b86c3cdf;hpb=1342825401e6e9e079eeec212271046930e1f475;p=friendica.git diff --git a/src/Model/APContact.php b/src/Model/APContact.php index 37faf240ce..7a63e413ca 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -1,6 +1,6 @@ getBody()) || + (!$curlResult->isSuccess() && ($curlResult->getReturnCode() != 410)); + + if (!$failed) { + $data = json_decode($curlResult->getBody(), true); + $failed = empty($data) || !is_array($data); + } + + if (!$failed && ($curlResult->getReturnCode() == 410)) { + $data = ['@context' => ActivityPub::CONTEXT, 'id' => $url, 'type' => 'Tombstone']; + } + + if ($failed) { self::markForArchival($fetched_contact ?: []); return $fetched_contact; } $compacted = JsonLD::compact($data); - if (empty($compacted['@id'])) { return $fetched_contact; } @@ -207,8 +218,11 @@ class APContact } // Quit if none of the basic values are set - if (empty($apcontact['url']) || empty($apcontact['inbox']) || empty($apcontact['type'])) { + if (empty($apcontact['url']) || empty($apcontact['type']) || (($apcontact['type'] != 'Tombstone') && empty($apcontact['inbox']))) { return $fetched_contact; + } elseif ($apcontact['type'] == 'Tombstone') { + // The "inbox" field must have a content + $apcontact['inbox'] = ''; } // Quit if this doesn't seem to be an account at all @@ -221,7 +235,7 @@ class APContact unset($parts['path']); if (empty($apcontact['addr'])) { - if (!empty($apcontact['nick'])) { + if (!empty($apcontact['nick']) && is_array($parts)) { $apcontact['addr'] = $apcontact['nick'] . '@' . str_replace('//', '', Network::unparseURL($parts)); } else { $apcontact['addr'] = ''; @@ -244,29 +258,23 @@ class APContact } if (!empty($apcontact['following'])) { - $data = ActivityPub::fetchContent($apcontact['following']); - if (!empty($data)) { - if (!empty($data['totalItems'])) { - $apcontact['following_count'] = $data['totalItems']; - } + $following = ActivityPub::fetchContent($apcontact['following']); + if (!empty($following['totalItems'])) { + $apcontact['following_count'] = $following['totalItems']; } } if (!empty($apcontact['followers'])) { - $data = ActivityPub::fetchContent($apcontact['followers']); - if (!empty($data)) { - if (!empty($data['totalItems'])) { - $apcontact['followers_count'] = $data['totalItems']; - } + $followers = ActivityPub::fetchContent($apcontact['followers']); + if (!empty($followers['totalItems'])) { + $apcontact['followers_count'] = $followers['totalItems']; } } if (!empty($apcontact['outbox'])) { - $data = ActivityPub::fetchContent($apcontact['outbox']); - if (!empty($data)) { - if (!empty($data['totalItems'])) { - $apcontact['statuses_count'] = $data['totalItems']; - } + $outbox = ActivityPub::fetchContent($apcontact['outbox']); + if (!empty($outbox['totalItems'])) { + $apcontact['statuses_count'] = $outbox['totalItems']; } } @@ -319,7 +327,7 @@ class APContact if (empty($apcontact['subscribe'])) { $apcontact['subscribe'] = null; - } + } if (!empty($apcontact['baseurl']) && empty($fetched_contact['gsid'])) { $apcontact['gsid'] = GServer::getID($apcontact['baseurl']);