. * */ namespace Friendica\Module\Api\Mastodon\Accounts; use Friendica\Core\System; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Module\BaseApi; /** * @see https://docs.joinmastodon.org/methods/accounts/ */ class Unfollow extends BaseApi { protected function post(array $request = []) { $this->checkAllowedScope(self::SCOPE_FOLLOW); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid); if (empty($cdata['user'])) { $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } $contact = Contact::getById($cdata['user']); Contact::unfollow($contact); $this->jsonExit(DI::mstdnRelationship()->createFromContactId($this->parameters['id'], $uid)->toArray()); } }