. * */ namespace Friendica\Module\Api\Mastodon\Accounts; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Module\BaseApi; /** * @see https://docs.joinmastodon.org/methods/accounts/ */ class Lists extends BaseApi { /** * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ protected function rawContent(array $request = []) { self::checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { DI::mstdnError()->UnprocessableEntity(); } $id = $this->parameters['id']; if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) { DI::mstdnError()->RecordNotFound(); } $lists = []; $cdata = Contact::getPublicAndUserContactID($id, $uid); if (!empty($cdata['user'])) { $circles = DBA::select('group_member', ['gid'], ['contact-id' => $cdata['user']]); while ($circle = DBA::fetch($circles)) { $lists[] = DI::mstdnList()->createFromCircleId($circle['gid']); } DBA::close($circles); } $this->jsonExit($lists); } }