+ return DBA::selectFirst('apcontact', [], ['url' => $apcontact['url']]) ?: [];
+ }
+
+ /**
+ * Mark the given AP Contact as "to archive"
+ *
+ * @param array $apcontact
+ * @return void
+ */
+ public static function markForArchival(array $apcontact)
+ {
+ if (!empty($apcontact['inbox'])) {
+ Logger::info('Set inbox status to failure', ['inbox' => $apcontact['inbox']]);
+ HTTPSignature::setInboxStatus($apcontact['inbox'], false);
+ }
+
+ if (!empty($apcontact['sharedinbox'])) {
+ // Check if there are any available inboxes
+ $available = DBA::exists('apcontact', ["`sharedinbox` = ? AnD `inbox` IN (SELECT `url` FROM `inbox-status` WHERE `success` > `failure`)",
+ $apcontact['sharedinbox']]);
+ 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);
+ }
+ }
+ }
+
+ /**
+ * Unmark the given AP Contact as "to archive"
+ *
+ * @param array $apcontact
+ * @return void
+ */
+ public static function unmarkForArchival(array $apcontact)
+ {
+ if (!empty($apcontact['inbox'])) {
+ Logger::info('Set inbox status to success', ['inbox' => $apcontact['inbox']]);
+ HTTPSignature::setInboxStatus($apcontact['inbox'], true);
+ }
+ if (!empty($apcontact['sharedinbox'])) {
+ Logger::info('Set shared inbox status to success', ['sharedinbox' => $apcontact['sharedinbox']]);
+ HTTPSignature::setInboxStatus($apcontact['sharedinbox'], true, true);
+ }