Issue 12358: Allow blocking of every contact

This commit is contained in:
Michael 2023-01-23 21:44:30 +00:00
parent d0373ab414
commit c471a78b05

View File

@ -41,26 +41,17 @@ class Block extends BaseApi
DI::mstdnError()->UnprocessableEntity(); DI::mstdnError()->UnprocessableEntity();
} }
$owner = User::getOwnerDataById($uid); Contact\User::setBlocked($this->parameters['id'], $uid, true);
if (empty($owner)) {
DI::mstdnError()->Forbidden();
}
$cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
if (empty($cdata['user'])) { if (!empty($cdata['user'])) {
DI::mstdnError()->RecordNotFound(); $contact = Contact::getById($cdata['user']);
if (!empty($contact)) {
// Mastodon-expected behavior: relationship is severed on block
Contact::terminateFriendship($contact);
}
} }
$contact = Contact::getById($cdata['user']);
if (empty($contact)) {
DI::mstdnError()->RecordNotFound();
}
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()); System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
} }
} }