Skip to content

Commit

Permalink
[TwitterBridge] Add option to hide pinned tweet (#1908)
Browse files Browse the repository at this point in the history
  • Loading branch information
fivefilters authored Jan 10, 2021
1 parent e128ce8 commit f927781
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bridges/TwitterBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)); */
Expand All @@ -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);
Expand Down

0 comments on commit f927781

Please sign in to comment.