[TwitterBridge] Skip advertisment tweets (#1673)

This commit is contained in:
Eugene Molotov 2020-09-11 11:44:28 +05:00 committed by GitHub
parent d6f277d029
commit 6c244f4d9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -210,6 +210,17 @@ EOD
$hidePictures = $this->getInput('nopic'); $hidePictures = $this->getInput('nopic');
$promotedTweetIds = array_reduce($data->timeline->instructions[0]->addEntries->entries, function($carry, $entry) {
if (!isset($entry->content->item)) {
return $carry;
}
$tweet = $entry->content->item->content->tweet;
if (isset($tweet->promotedMetadata)) {
$carry[] = $tweet->id;
}
return $carry;
}, array());
foreach($data->globalObjects->tweets as $tweet) { foreach($data->globalObjects->tweets as $tweet) {
/* Debug::log('>>> ' . json_encode($tweet)); */ /* Debug::log('>>> ' . json_encode($tweet)); */
@ -218,6 +229,11 @@ EOD
continue; continue;
} }
// Skip promoted tweets
if (in_array($tweet->id_str, $promotedTweetIds)) {
continue;
}
$item = array(); $item = array();
// extract username and sanitize // extract username and sanitize
$user_info = $this->getUserInformation($tweet->user_id_str, $data->globalObjects); $user_info = $this->getUserInformation($tweet->user_id_str, $data->globalObjects);