kopia lustrzana https://github.com/friendica/friendica
Implement relationship termination for Mastodon block
- This is the expected Mastodon behavior on blockpull/10800/head
rodzic
b0d8136b00
commit
bd42f5757f
|
@ -24,6 +24,7 @@ namespace Friendica\Module\Api\Mastodon\Accounts;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +41,26 @@ class Block extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
Contact\User::setBlocked($parameters['id'], $uid, true);
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
if (empty($owner)) {
|
||||
DI::mstdnError()->Forbidden();
|
||||
}
|
||||
|
||||
$cdata = Contact::getPublicAndUserContactID($parameters['id'], $uid);
|
||||
if (empty($cdata['user'])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
$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($owner, $contact);
|
||||
Contact::revokeFollow($contact);
|
||||
|
||||
System::jsonExit(DI::mstdnRelationship()->createFromContactId($parameters['id'], $uid)->toArray());
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue