Move unfollow protocol to worker task

- Add uid parameter to unfollow hook
- Rework and unify Contact::unfollow, Contact::removeSharer and Contact::terminateFriendship
- Add missing twitterUser property to Twitter\Friendships\Destroy module
This commit is contained in:
Hypolite Petovan 2021-10-16 21:24:34 -04:00
parent 48e2963ac7
commit 6a1f9a7fa3
11 changed files with 159 additions and 78 deletions

View file

@ -59,8 +59,7 @@ class Block extends BaseApi
Contact\User::setBlocked($cdata['user'], $uid, true);
// Mastodon-expected behavior: relationship is severed on block
Contact::terminateFriendship($owner, $contact);
Contact::revokeFollow($contact);
Contact::terminateFriendship($contact);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}

View file

@ -40,7 +40,14 @@ class Unfollow extends BaseApi
DI::mstdnError()->UnprocessableEntity();
}
Contact::unfollow($this->parameters['id'], $uid);
$cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
if (empty($cdata['user'])) {
DI::mstdnError()->RecordNotFound();
}
$contact = Contact::getById($cdata['user']);
Contact::unfollow($contact);
System::jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray());
}