+ /**
+ * @brief Checks if the contact is archived
+ *
+ * @param int $cid contact id
+ *
+ * @return boolean Is the contact archived?
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ */
+ public static function isArchived(int $cid)
+ {
+ if ($cid == 0) {
+ return false;
+ }
+
+ $contact = DBA::selectFirst('contact', ['archive', 'url', 'batch'], ['id' => $cid]);
+ if (!DBA::isResult($contact)) {
+ return false;
+ }
+
+ if ($contact['archive']) {
+ return true;
+ }
+
+ // Check status of ActivityPub endpoints
+ $apcontact = APContact::getByURL($contact['url'], false);
+ if (!empty($apcontact)) {
+ if (!empty($apcontact['inbox']) && DBA::exists('inbox-status', ['archive' => true, 'url' => $apcontact['inbox']])) {
+ return true;
+ }
+
+ if (!empty($apcontact['sharedinbox']) && DBA::exists('inbox-status', ['archive' => true, 'url' => $apcontact['sharedinbox']])) {
+ return true;
+ }
+ }
+
+ // Check status of Diaspora endpoints
+ if (!empty($contact['batch'])) {
+ $condition = ['archive' => true, 'uid' => 0, 'network' => Protocol::FEDERATED, 'batch' => $contact['batch'], 'contact-type' => self::TYPE_RELAY];
+ return DBA::exists('contact', $condition);
+ }
+
+ return false;
+ }
+