<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
namespace Friendica\Object\Api\Mastodon;
use Friendica\App\BaseURL;
-use Friendica\BaseEntity;
+use Friendica\BaseDataTransferObject;
use Friendica\Collection\Api\Mastodon\Fields;
use Friendica\Content\Text\BBCode;
use Friendica\Database\DBA;
*
* @see https://docs.joinmastodon.org/entities/account
*/
-class Account extends BaseEntity
+class Account extends BaseDataTransferObject
{
/** @var string */
protected $id;
$publicContact['nick'] :
$publicContact['addr'];
$this->display_name = $publicContact['name'];
- $this->locked = $publicContact['manually-approve'] ?? !empty($apcontact['manually-approve']);
+ $this->locked = (bool)$publicContact['manually-approve'] ?? !empty($apcontact['manually-approve']);
$this->bot = ($publicContact['contact-type'] == Contact::TYPE_NEWS);
$this->discoverable = !$publicContact['unsearchable'];
$this->group = ($publicContact['contact-type'] == Contact::TYPE_COMMUNITY);
$userContactCreated = $userContact['created'] ?? DBA::NULL_DATETIME;
$created = $userContactCreated < $publicContactCreated && ($userContactCreated != DBA::NULL_DATETIME) ? $userContactCreated : $publicContactCreated;
- $this->created_at = DateTimeFormat::utc($created, DateTimeFormat::ATOM);
+ $this->created_at = DateTimeFormat::utc($created, DateTimeFormat::JSON);
$this->note = BBCode::convert($publicContact['about'], false);
$this->url = $publicContact['url'];
$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;
+ }
}