From 1ced8488277d9c20dd75ef7595f2bc904190b894 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 1 Mar 2025 14:40:50 +0000 Subject: [PATCH] Fix codestyle --- src/Object/Api/Mastodon/Account.php | 31 +++++++++-------- src/Object/Api/Mastodon/Card.php | 18 +++++----- src/Object/Api/Mastodon/Status.php | 52 ++++++++++++++--------------- 3 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/Object/Api/Mastodon/Account.php b/src/Object/Api/Mastodon/Account.php index 864b263cca..b4009b6e69 100644 --- a/src/Object/Api/Mastodon/Account.php +++ b/src/Object/Api/Mastodon/Account.php @@ -84,20 +84,19 @@ class Account extends BaseDataTransferObject */ public function __construct(BaseURL $baseUrl, array $account, Fields $fields) { - $this->id = (string)$account['pid']; - $this->username = $account['nick']; - $this->acct = - strpos($account['url'], $baseUrl . '/') === 0 ? + $this->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->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->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']; @@ -108,14 +107,14 @@ class Account extends BaseDataTransferObject $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; + $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; + $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(); + $this->emojis = []; + $this->fields = $fields->getArrayCopy(); } /** diff --git a/src/Object/Api/Mastodon/Card.php b/src/Object/Api/Mastodon/Card.php index 9b9c58db1b..0de3f9c499 100644 --- a/src/Object/Api/Mastodon/Card.php +++ b/src/Object/Api/Mastodon/Card.php @@ -61,18 +61,18 @@ class Card extends BaseDataTransferObject */ public function __construct(array $attachment, array $history = []) { - $this->url = $attachment['url'] ?? ''; - $this->title = $attachment['title'] ?? ''; - $this->description = $attachment['description'] ?? ''; - $this->type = $attachment['type'] ?? ''; - $this->author_name = $attachment['author_name'] ?? ''; - $this->author_url = $attachment['author_url'] ?? ''; + $this->url = $attachment['url'] ?? ''; + $this->title = $attachment['title'] ?? ''; + $this->description = $attachment['description'] ?? ''; + $this->type = $attachment['type'] ?? ''; + $this->author_name = $attachment['author_name'] ?? ''; + $this->author_url = $attachment['author_url'] ?? ''; $this->provider_name = $attachment['provider_name'] ?? ''; - $this->provider_url = $attachment['provider_url'] ?? ''; + $this->provider_url = $attachment['provider_url'] ?? ''; $this->html = ''; - $this->width = $attachment['width'] ?? 0; + $this->width = $attachment['width'] ?? 0; $this->height = $attachment['height'] ?? 0; - $this->image = $attachment['image'] ?? ''; + $this->image = $attachment['image'] ?? ''; $this->embed_url = ''; $this->blurhash = $attachment['blurhash'] ?? ''; $this->history = $history; diff --git a/src/Object/Api/Mastodon/Status.php b/src/Object/Api/Mastodon/Status.php index 16eba0afcb..9f68d27d14 100644 --- a/src/Object/Api/Mastodon/Status.php +++ b/src/Object/Api/Mastodon/Status.php @@ -97,10 +97,10 @@ class Status extends BaseDataTransferObject */ public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $in_reply, array $reblog, FriendicaExtension $friendica, array $quote = null, array $poll = null, array $emojis = null) { - $reblogged = !empty($reblog); - $this->id = (string)$item['uri-id']; - $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON); - $this->edited_at = DateTimeFormat::utc($item['edited'], DateTimeFormat::JSON); + $reblogged = !empty($reblog); + $this->id = (string)$item['uri-id']; + $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON); + $this->edited_at = DateTimeFormat::utc($item['edited'], DateTimeFormat::JSON); if ($item['gravity'] == Item::GRAVITY_COMMENT) { $this->in_reply_to_id = (string)$item['thr-parent-id']; @@ -111,7 +111,7 @@ class Status extends BaseDataTransferObject $this->sensitive = $sensitive; $this->spoiler_text = $item['title'] ?: $item['content-warning'] ?: ''; - $visibility = ['public', 'private', 'unlisted']; + $visibility = ['public', 'private', 'unlisted']; $this->visibility = $visibility[$item['private']]; $languages = json_decode($item['language'] ?? '', true); @@ -122,28 +122,28 @@ class Status extends BaseDataTransferObject $this->language = null; } - $this->uri = $item['uri']; - $this->url = $item['plink'] ?? null; - $this->replies_count = $reblogged ? 0 : $counts->replies; - $this->reblogs_count = $reblogged ? 0 : $counts->reblogs; - $this->favourites_count = $reblogged ? 0 : $counts->favourites; - $this->favourited = $userAttributes->favourited; - $this->reblogged = $userAttributes->reblogged; - $this->muted = $userAttributes->muted; - $this->bookmarked = $userAttributes->bookmarked; - $this->pinned = $userAttributes->pinned; - $this->content = $reblogged ? '' : BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($item['raw-body'] ?? $item['body']), BBCode::MASTODON_API); - $this->reblog = $reblog; - $this->quote = $quote; - $this->application = $application->toArray(); - $this->account = $account->toArray(); + $this->uri = $item['uri']; + $this->url = $item['plink'] ?? null; + $this->replies_count = $reblogged ? 0 : $counts->replies; + $this->reblogs_count = $reblogged ? 0 : $counts->reblogs; + $this->favourites_count = $reblogged ? 0 : $counts->favourites; + $this->favourited = $userAttributes->favourited; + $this->reblogged = $userAttributes->reblogged; + $this->muted = $userAttributes->muted; + $this->bookmarked = $userAttributes->bookmarked; + $this->pinned = $userAttributes->pinned; + $this->content = $reblogged ? '' : BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($item['raw-body'] ?? $item['body']), BBCode::MASTODON_API); + $this->reblog = $reblog; + $this->quote = $quote; + $this->application = $application->toArray(); + $this->account = $account->toArray(); $this->media_attachments = $reblogged ? [] : $attachments; - $this->mentions = $reblogged ? [] : $mentions; - $this->tags = $reblogged ? [] : $tags; - $this->emojis = $reblogged ? [] : ($emojis ?: []); - $this->card = $reblogged ? null : ($card->toArray() ?: null); - $this->poll = $reblogged ? null : $poll; - $this->friendica = $reblogged ? null : $friendica; + $this->mentions = $reblogged ? [] : $mentions; + $this->tags = $reblogged ? [] : $tags; + $this->emojis = $reblogged ? [] : ($emojis ?: []); + $this->card = $reblogged ? null : ($card->toArray() ?: null); + $this->poll = $reblogged ? null : $poll; + $this->friendica = $reblogged ? null : $friendica; } /**