]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Api/Mastodon/Account.php
Merge pull request #10359 from annando/milliseconds
[friendica.git] / src / Object / Api / Mastodon / Account.php
index f6e66941ac7094a4d3f3c9dfda1e8aad1857c8f0..f9c77675fa73680714af79ccea7b47e0ba28a861 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -22,7 +22,7 @@
 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;
@@ -34,7 +34,7 @@ use Friendica\Util\DateTimeFormat;
  *
  * @see https://docs.joinmastodon.org/entities/account
  */
-class Account extends BaseEntity
+class Account extends BaseDataTransferObject
 {
        /** @var string */
        protected $id;
@@ -108,7 +108,7 @@ class Account extends BaseEntity
                $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'];
@@ -132,4 +132,20 @@ class Account extends BaseEntity
                $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;
+       }
 }