id = (string)$account['pid']; $this->username = $account['nick']; $this->acct = strpos($account['url'], $baseUrl . '/') === 0 ? $account['nick'] : $account['addr']; $this->display_name = $account['name']; $this->locked = (bool)$account['manually-approve']; $this->bot = ($account['contact-type'] == Contact::TYPE_NEWS); $this->discoverable = !$account['unsearchable']; $this->indexable = $this->discoverable; $this->group = ($account['contact-type'] == Contact::TYPE_COMMUNITY); $this->created_at = DateTimeFormat::utc($account['created'] ?: DBA::NULL_DATETIME, DateTimeFormat::JSON); $this->note = BBCode::convertForUriId($account['uri-id'], $account['about'], BBCode::EXTERNAL); $this->url = $account['alias'] ?: $account['url']; $this->uri = $account['url']; $this->avatar = Contact::getAvatarUrlForId($account['id'] ?? 0 ?: $account['pid'], Proxy::SIZE_SMALL, $account['updated'], $account['guid'] ?? ''); $this->avatar_static = Contact::getAvatarUrlForId($account['id'] ?? 0 ?: $account['pid'], Proxy::SIZE_SMALL, $account['updated'], $account['guid'] ?? '', true); $this->header = Contact::getHeaderUrlForId($account['id'] ?? 0 ?: $account['pid'], '', $account['updated'], $account['guid'] ?? ''); $this->header_static = Contact::getHeaderUrlForId($account['id'] ?? 0 ?: $account['pid'], '', $account['updated'], $account['guid'] ?? '', true); $this->followers_count = $account['ap-followers_count'] ?? $account['diaspora-interacted_count'] ?? 0; $this->following_count = $account['ap-following_count'] ?? $account['diaspora-interacting_count'] ?? 0; $this->statuses_count = $account['ap-statuses_count'] ?? $account['diaspora-post_count'] ?? 0; $lastItem = $account['last-item'] ? DateTimeFormat::utc($account['last-item'], 'Y-m-d') : DBA::NULL_DATETIME; $this->last_status_at = $lastItem != DBA::NULL_DATETIME ? DateTimeFormat::utc($lastItem, DateTimeFormat::JSON) : null; // No custom emojis per account in Friendica $this->emojis = []; $this->fields = $fields->getArrayCopy(); } /** * Returns the current entity as an array * * @return array */ public function toArray(): array { $account = parent::toArray(); if (empty($account['moved'])) { unset($account['moved']); } return $account; } }