From c471a78b055f5e83e269e442a6970a4a5a9f7ae1 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 23 Jan 2023 21:44:30 +0000 Subject: [PATCH] Issue 12358: Allow blocking of every contact --- src/Module/Api/Mastodon/Accounts/Block.php | 23 +++++++--------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/Module/Api/Mastodon/Accounts/Block.php b/src/Module/Api/Mastodon/Accounts/Block.php index 43d56a3b68..e13a8b2ff4 100644 --- a/src/Module/Api/Mastodon/Accounts/Block.php +++ b/src/Module/Api/Mastodon/Accounts/Block.php @@ -41,26 +41,17 @@ class Block extends BaseApi DI::mstdnError()->UnprocessableEntity(); } - $owner = User::getOwnerDataById($uid); - if (empty($owner)) { - DI::mstdnError()->Forbidden(); - } + Contact\User::setBlocked($this->parameters['id'], $uid, true); $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); - if (empty($cdata['user'])) { - DI::mstdnError()->RecordNotFound(); - } - - $contact = Contact::getById($cdata['user']); - if (empty($contact)) { - DI::mstdnError()->RecordNotFound(); + if (!empty($cdata['user'])) { + $contact = Contact::getById($cdata['user']); + if (!empty($contact)) { + // Mastodon-expected behavior: relationship is severed on block + Contact::terminateFriendship($contact); + } } - Contact\User::setBlocked($cdata['user'], $uid, true); - - // Mastodon-expected behavior: relationship is severed on block - Contact::terminateFriendship($contact); - System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } } -- 2.39.5