From 18f3ff7b8ef0ea52f9b74563c3b7885214dab220 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Mar 2019 22:43:00 +0000 Subject: [PATCH] Unarchive inboxes on profile update --- src/Model/APContact.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Model/APContact.php b/src/Model/APContact.php index bf36306b41..4ae6dbd1dc 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -123,11 +123,14 @@ class APContact extends BaseObject $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']); + $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']); } $apcontact['nick'] = JsonLD::fetchElement($compacted, 'as:preferredUsername'); @@ -231,4 +234,27 @@ class APContact extends BaseObject return $apcontact; } + + /** + * Unarchive inboxes + * + * @param string $url inbox url + */ + private static function unarchiveInbox($url) + { + if (empty($url)) { + return; + } + + $now = DateTimeFormat::utcNow(); + + if (!DBA::exists('inbox-status', ['url' => $url])) { + $fields = ['archive' => false, 'success' => $now, + 'url' => $url, 'created' => $now]; + DBA::insert('inbox-status', $fields); + } else { + $fields = ['archive' => false, 'success' => $now]; + DBA::update('inbox-status', $fields, ['url' => $url]); + } + } }