PDA

View Full Version : Working with rssposter_parse_rss hook


AndrewRich
07-10-2012, 10:30 PM
I'm trying to implement a source blocklist for our RSS feeds - we get newsfeeds from Google News and rather than trying to figure out Google's broken news-source nomenclature, I will just block items from unwanted sources from posting. I'm hooking rssposter_parse_rss and have defined a blocklist as $vbulletin->options['rssitemsourcefilter_blacklist']. Here's my plugin code so far:


global $vbulletin;

if ( $vbulletin->options['rssitemsourcefilter_enabled']) {
$blacklistA = preg_split ( '/\s+/', $vbulletin->options['rssitemsourcefilter_blacklist'] );
foreach ( $blacklistA as $blacklist ) {
if ( stripos ( $item['link'], $blacklist ) !== FALSE ) {
// link source appears in blacklist
if (defined('IN_CONTROL_PANEL')) {
echo "<p>RSS feed item with source {$blacklist} was blocked.</p>";
}
$item = NULL; // nullify the RSS item
} // if
} // foreach
} // if


This does "empty out" the particular RSS item but it doesn't actually remove it from the queue, so instead a blank entry with a no-destination "more" link is posted. I've been going through /includes/class_rss_poster.php and /includes/cron/rssposter.php to try to figure out how to actually remove the offending item, but without any luck.

Any help appreciated. Thanks.

kh99
07-10-2012, 11:25 PM
Unfortunately, I don't see how you can do what you want to do using that hook, and there really aren't any other hooks in the rss poster code. The only thing I can think of offhand is if you're posting the item as threads, you might be able to use a hook like threadfpdata_doset to set an error as if one of the fields were invalid, then when the rss poster calls save() to post the thread, it will fail. But to do that you need a way to detect that it's the rss poster cron job creating the thread, and you also need to be able to check the source.

Of course editing the vb files is always another option.

AndrewRich
07-11-2012, 02:16 AM
Kevin, thanks for your reply. I know I could add a little something to class_rss_poster or rssposter but was hoping to avoid that. I'll look at perhaps setting a flag that another hook might see. Thanks again.