Fix codestyle

This commit is contained in:
Michael 2025-03-01 14:40:50 +00:00
parent fb9a20feaa
commit 1ced848827
3 changed files with 50 additions and 51 deletions

View file

@ -84,20 +84,19 @@ class Account extends BaseDataTransferObject
*/ */
public function __construct(BaseURL $baseUrl, array $account, Fields $fields) public function __construct(BaseURL $baseUrl, array $account, Fields $fields)
{ {
$this->id = (string)$account['pid']; $this->id = (string)$account['pid'];
$this->username = $account['nick']; $this->username = $account['nick'];
$this->acct = $this->acct = strpos($account['url'], $baseUrl . '/') === 0 ?
strpos($account['url'], $baseUrl . '/') === 0 ?
$account['nick'] : $account['nick'] :
$account['addr']; $account['addr'];
$this->display_name = $account['name']; $this->display_name = $account['name'];
$this->locked = (bool)$account['manually-approve']; $this->locked = (bool)$account['manually-approve'];
$this->bot = ($account['contact-type'] == Contact::TYPE_NEWS); $this->bot = ($account['contact-type'] == Contact::TYPE_NEWS);
$this->discoverable = !$account['unsearchable']; $this->discoverable = !$account['unsearchable'];
$this->indexable = $this->discoverable; $this->indexable = $this->discoverable;
$this->group = ($account['contact-type'] == Contact::TYPE_COMMUNITY); $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->note = BBCode::convertForUriId($account['uri-id'], $account['about'], BBCode::EXTERNAL);
$this->url = $account['alias'] ?: $account['url']; $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->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->followers_count = $account['ap-followers_count'] ?? $account['diaspora-interacted_count'] ?? 0;
$this->following_count = $account['ap-following_count'] ?? $account['diaspora-interacting_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; $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; $this->last_status_at = $lastItem != DBA::NULL_DATETIME ? DateTimeFormat::utc($lastItem, DateTimeFormat::JSON) : null;
// No custom emojis per account in Friendica // No custom emojis per account in Friendica
$this->emojis = []; $this->emojis = [];
$this->fields = $fields->getArrayCopy(); $this->fields = $fields->getArrayCopy();
} }
/** /**

View file

@ -61,18 +61,18 @@ class Card extends BaseDataTransferObject
*/ */
public function __construct(array $attachment, array $history = []) public function __construct(array $attachment, array $history = [])
{ {
$this->url = $attachment['url'] ?? ''; $this->url = $attachment['url'] ?? '';
$this->title = $attachment['title'] ?? ''; $this->title = $attachment['title'] ?? '';
$this->description = $attachment['description'] ?? ''; $this->description = $attachment['description'] ?? '';
$this->type = $attachment['type'] ?? ''; $this->type = $attachment['type'] ?? '';
$this->author_name = $attachment['author_name'] ?? ''; $this->author_name = $attachment['author_name'] ?? '';
$this->author_url = $attachment['author_url'] ?? ''; $this->author_url = $attachment['author_url'] ?? '';
$this->provider_name = $attachment['provider_name'] ?? ''; $this->provider_name = $attachment['provider_name'] ?? '';
$this->provider_url = $attachment['provider_url'] ?? ''; $this->provider_url = $attachment['provider_url'] ?? '';
$this->html = ''; $this->html = '';
$this->width = $attachment['width'] ?? 0; $this->width = $attachment['width'] ?? 0;
$this->height = $attachment['height'] ?? 0; $this->height = $attachment['height'] ?? 0;
$this->image = $attachment['image'] ?? ''; $this->image = $attachment['image'] ?? '';
$this->embed_url = ''; $this->embed_url = '';
$this->blurhash = $attachment['blurhash'] ?? ''; $this->blurhash = $attachment['blurhash'] ?? '';
$this->history = $history; $this->history = $history;

View file

@ -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) 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); $reblogged = !empty($reblog);
$this->id = (string)$item['uri-id']; $this->id = (string)$item['uri-id'];
$this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON); $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON);
$this->edited_at = DateTimeFormat::utc($item['edited'], DateTimeFormat::JSON); $this->edited_at = DateTimeFormat::utc($item['edited'], DateTimeFormat::JSON);
if ($item['gravity'] == Item::GRAVITY_COMMENT) { if ($item['gravity'] == Item::GRAVITY_COMMENT) {
$this->in_reply_to_id = (string)$item['thr-parent-id']; $this->in_reply_to_id = (string)$item['thr-parent-id'];
@ -111,7 +111,7 @@ class Status extends BaseDataTransferObject
$this->sensitive = $sensitive; $this->sensitive = $sensitive;
$this->spoiler_text = $item['title'] ?: $item['content-warning'] ?: ''; $this->spoiler_text = $item['title'] ?: $item['content-warning'] ?: '';
$visibility = ['public', 'private', 'unlisted']; $visibility = ['public', 'private', 'unlisted'];
$this->visibility = $visibility[$item['private']]; $this->visibility = $visibility[$item['private']];
$languages = json_decode($item['language'] ?? '', true); $languages = json_decode($item['language'] ?? '', true);
@ -122,28 +122,28 @@ class Status extends BaseDataTransferObject
$this->language = null; $this->language = null;
} }
$this->uri = $item['uri']; $this->uri = $item['uri'];
$this->url = $item['plink'] ?? null; $this->url = $item['plink'] ?? null;
$this->replies_count = $reblogged ? 0 : $counts->replies; $this->replies_count = $reblogged ? 0 : $counts->replies;
$this->reblogs_count = $reblogged ? 0 : $counts->reblogs; $this->reblogs_count = $reblogged ? 0 : $counts->reblogs;
$this->favourites_count = $reblogged ? 0 : $counts->favourites; $this->favourites_count = $reblogged ? 0 : $counts->favourites;
$this->favourited = $userAttributes->favourited; $this->favourited = $userAttributes->favourited;
$this->reblogged = $userAttributes->reblogged; $this->reblogged = $userAttributes->reblogged;
$this->muted = $userAttributes->muted; $this->muted = $userAttributes->muted;
$this->bookmarked = $userAttributes->bookmarked; $this->bookmarked = $userAttributes->bookmarked;
$this->pinned = $userAttributes->pinned; $this->pinned = $userAttributes->pinned;
$this->content = $reblogged ? '' : BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($item['raw-body'] ?? $item['body']), BBCode::MASTODON_API); $this->content = $reblogged ? '' : BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($item['raw-body'] ?? $item['body']), BBCode::MASTODON_API);
$this->reblog = $reblog; $this->reblog = $reblog;
$this->quote = $quote; $this->quote = $quote;
$this->application = $application->toArray(); $this->application = $application->toArray();
$this->account = $account->toArray(); $this->account = $account->toArray();
$this->media_attachments = $reblogged ? [] : $attachments; $this->media_attachments = $reblogged ? [] : $attachments;
$this->mentions = $reblogged ? [] : $mentions; $this->mentions = $reblogged ? [] : $mentions;
$this->tags = $reblogged ? [] : $tags; $this->tags = $reblogged ? [] : $tags;
$this->emojis = $reblogged ? [] : ($emojis ?: []); $this->emojis = $reblogged ? [] : ($emojis ?: []);
$this->card = $reblogged ? null : ($card->toArray() ?: null); $this->card = $reblogged ? null : ($card->toArray() ?: null);
$this->poll = $reblogged ? null : $poll; $this->poll = $reblogged ? null : $poll;
$this->friendica = $reblogged ? null : $friendica; $this->friendica = $reblogged ? null : $friendica;
} }
/** /**