. * */ namespace Friendica\Module\Api\Mastodon\Tags; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Module\BaseApi; /** * @see https://docs.joinmastodon.org/methods/tags/#unfollow */ class Unfollow extends BaseApi { protected function post(array $request = []) { $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['hashtag'])) { $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } $term = ['uid' => $uid, 'term' => '#' . ltrim($this->parameters['hashtag'], '#')]; DBA::delete('search', $term); $hashtag = new \Friendica\Object\Api\Mastodon\Tag($this->baseUrl, ['name' => ltrim($this->parameters['hashtag'])], [], false); $this->jsonExit($hashtag->toArray()); } }