]> 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 5bd2743b9e0cb9acb0e724c95dec11682a989d11..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;
@@ -99,7 +99,7 @@ class Account extends BaseEntity
                                $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);
@@ -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;
+       }
 }