From d08b2616ef1adfa69edc10f42e4e7fcb0c9226cb Mon Sep 17 00:00:00 2001 From: Dag Date: Fri, 21 Jul 2023 20:26:22 +0200 Subject: [PATCH] feat(twitter): use account icon as feed icon, fix #3348 (#3561) --- bridges/TwitterBridge.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index f0f0ee52..189203bd 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -124,6 +124,7 @@ EOD private $apiKey = null; private $guestToken = null; private $authHeaders = []; + private ?string $feedIconUrl = null; public function detectParameters($url) { @@ -309,6 +310,10 @@ EOD } } + if ($this->queriedContext === 'By username') { + $this->feedIconUrl = $data->user_info->legacy->profile_image_url_https ?? null; + } + foreach ($tweets as $tweet) { // Skip own Retweets... if (isset($tweet->retweeted_status) && $tweet->retweeted_status->user->id_str === $tweet->user->id_str) { @@ -497,6 +502,11 @@ EOD; usort($this->items, ['TwitterBridge', 'compareTweetId']); } + public function getIcon() + { + return $this->feedIconUrl ?? parent::getIcon(); + } + private static function compareTweetId($tweet1, $tweet2) { return (intval($tweet1['id']) < intval($tweet2['id']) ? 1 : -1);