feat(twitter): use account icon as feed icon, fix #3348 (#3561)

This commit is contained in:
Dag 2023-07-21 20:26:22 +02:00 committed by GitHub
parent 0a118310cb
commit d08b2616ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -124,6 +124,7 @@ EOD
private $apiKey = null; private $apiKey = null;
private $guestToken = null; private $guestToken = null;
private $authHeaders = []; private $authHeaders = [];
private ?string $feedIconUrl = null;
public function detectParameters($url) 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) { foreach ($tweets as $tweet) {
// Skip own Retweets... // Skip own Retweets...
if (isset($tweet->retweeted_status) && $tweet->retweeted_status->user->id_str === $tweet->user->id_str) { 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']); usort($this->items, ['TwitterBridge', 'compareTweetId']);
} }
public function getIcon()
{
return $this->feedIconUrl ?? parent::getIcon();
}
private static function compareTweetId($tweet1, $tweet2) private static function compareTweetId($tweet1, $tweet2)
{ {
return (intval($tweet1['id']) < intval($tweet2['id']) ? 1 : -1); return (intval($tweet1['id']) < intval($tweet2['id']) ? 1 : -1);