From 479458a389e32a129085317bdaf84f7d8e9a0459 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 9 Oct 2021 02:09:01 -0400 Subject: [PATCH 1/3] Add missing parameters to Contact::block/unblock --- src/Model/Contact/User.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/Contact/User.php b/src/Model/Contact/User.php index 7d6ce17da..05530cccc 100644 --- a/src/Model/Contact/User.php +++ b/src/Model/Contact/User.php @@ -148,9 +148,9 @@ class User $contact = Contact::getById($cdata['public']); if ($blocked) { - Protocol::block($contact); + Protocol::block($contact, $uid); } else { - Protocol::unblock($contact); + Protocol::unblock($contact, $uid); } if ($cdata['user'] != 0) { From 5028258c3b7485cced4405b8a80f0754854a5606 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 9 Oct 2021 02:09:49 -0400 Subject: [PATCH 2/3] Remove exception throwing on null protocol action result in Console\Contact --- src/Console/Contact.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Console/Contact.php b/src/Console/Contact.php index cbfd4b6c6..ae0a9b11a 100644 --- a/src/Console/Contact.php +++ b/src/Console/Contact.php @@ -203,10 +203,6 @@ HELP; try { $result = ContactModel::terminateFriendship($user, $contact); - if ($result === null) { - throw new RuntimeException('Unfollowing is currently not supported by this contact\'s network.'); - } - if ($result === false) { throw new RuntimeException('Unable to unfollow this contact, please retry in a few minutes or check the logs.'); } @@ -222,8 +218,6 @@ HELP; /** * Marks a contact for removal - * - * @return bool True, if the command was successful */ private function removeContact() { @@ -236,7 +230,7 @@ HELP; } } - $result = ContactModel::remove($cid); + ContactModel::remove($cid); } /** From b214470b1a0e17750b8652200828d29eeedf6a51 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 9 Oct 2021 02:10:16 -0400 Subject: [PATCH 3/3] Replace remaining explicit network value checks by Protocol::supportsFollow calls --- mod/unfollow.php | 2 +- src/Content/Widget/VCard.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/unfollow.php b/mod/unfollow.php index d566ac3cf..ac8ed40c3 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -67,7 +67,7 @@ function unfollow_content(App $a) // NOTREACHED } - if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { + if (!Protocol::supportsFollow($contact['network'])) { notice(DI::l10n()->t('Unfollowing is currently not supported by your network.')); DI::baseUrl()->redirect($base_return_path . '/' . $contact['id']); // NOTREACHED diff --git a/src/Content/Widget/VCard.php b/src/Content/Widget/VCard.php index d66b60513..38b75272f 100644 --- a/src/Content/Widget/VCard.php +++ b/src/Content/Widget/VCard.php @@ -75,7 +75,7 @@ class VCard $pending = $pcontact['pending'] ?? false; } - if (!$contact['self'] && in_array($contact['network'], Protocol::NATIVE_SUPPORT)) { + if (!$contact['self'] && Protocol::supportsFollow($contact['network'])) { if (in_array($rel, [Contact::SHARING, Contact::FRIEND])) { $unfollow_link = 'unfollow?url=' . urlencode($contact['url']) . '&auto=1'; } elseif (!$pending) {