From 825189e8e908a027c4292f4f8dd5d2e84f9ac810 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 25 Oct 2020 17:42:42 +0000 Subject: [PATCH] Don't publish some fields --- src/Object/Api/Mastodon/Account.php | 16 ++++++++++++++++ src/Object/Api/Mastodon/Status.php | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/Object/Api/Mastodon/Account.php b/src/Object/Api/Mastodon/Account.php index f6e66941ac..587c6ce6d4 100644 --- a/src/Object/Api/Mastodon/Account.php +++ b/src/Object/Api/Mastodon/Account.php @@ -132,4 +132,20 @@ class Account extends BaseEntity $this->fields = $fields->getArrayCopy(); } + + /** + * Returns the current entity as an array + * + * @return array + */ + public function toArray() + { + $account = parent::toArray(); + + if (empty($account['moved'])) { + unset($account['moved']); + } + + return $account; + } } diff --git a/src/Object/Api/Mastodon/Status.php b/src/Object/Api/Mastodon/Status.php index cc9108fc8c..2d2beb583f 100644 --- a/src/Object/Api/Mastodon/Status.php +++ b/src/Object/Api/Mastodon/Status.php @@ -137,4 +137,24 @@ class Status extends BaseEntity $this->card = $card->toArray(); $this->poll = null; } + + /** + * Returns the current entity as an array + * + * @return array + */ + public function toArray() + { + $status = parent::toArray(); + + if (!$status['pinned']) { + unset($status['pinned']); + } + + if (empty($status['application']['name'])) { + unset($status['application']); + } + + return $status; + } }