From f927781750fc58bcd23c55f7d01483201c4ec88b Mon Sep 17 00:00:00 2001 From: "FiveFilters.org" Date: Sun, 10 Jan 2021 09:50:06 +0100 Subject: [PATCH] [TwitterBridge] Add option to hide pinned tweet (#1908) --- bridges/TwitterBridge.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index 8f546c6f090..c62a6595a91 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -75,6 +75,12 @@ class TwitterBridge extends BridgeAbstract { 'required' => false, 'type' => 'checkbox', 'title' => 'Hide retweets' + ), + 'nopinned' => array( + 'name' => 'Without pinned tweet', + 'required' => false, + 'type' => 'checkbox', + 'title' => 'Hide pinned tweet' ) ), 'By list' => array( @@ -246,6 +252,14 @@ public function collectData(){ return $carry; }, array()); + $hidePinned = $this->getInput('nopinned'); + if ($hidePinned) { + $pinnedTweetId = null; + if (isset($data->timeline->instructions[1]) && isset($data->timeline->instructions[1]->pinEntry)) { + $pinnedTweetId = $data->timeline->instructions[1]->pinEntry->entry->content->item->content->tweet->id; + } + } + foreach($data->globalObjects->tweets as $tweet) { /* Debug::log('>>> ' . json_encode($tweet)); */ @@ -259,6 +273,11 @@ public function collectData(){ continue; } + // Skip pinned tweet + if ($hidePinned && $tweet->id_str === $pinnedTweetId) { + continue; + } + $item = array(); // extract username and sanitize $user_info = $this->getUserInformation($tweet->user_id_str, $data->globalObjects);