We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit f5585087 authored by Evan Prodromou's avatar Evan Prodromou

handle RSS as well as Atom in Ostatus push hits

parent 65c8dc31
......@@ -388,11 +388,17 @@ class Ostatus_profile extends Memcached_DataObject
{
$feed = $doc->documentElement;
if ($feed->localName != 'feed' || $feed->namespaceURI != Activity::ATOM) {
common_log(LOG_ERR, __METHOD__ . ": not an Atom feed, ignoring");
return;
if ($feed->localName == 'feed' && $feed->namespaceURI == Activity::ATOM) {
$this->processAtomFeed($feed, $source);
} else if ($feed->localName == 'rss') { // @fixme check namespace
$this->processRssFeed($feed, $source);
} else {
throw new Exception("Unknown feed format.");
}
}
public function processAtomFeed(DOMElement $feed, $source)
{
$entries = $feed->getElementsByTagNameNS(Activity::ATOM, 'entry');
if ($entries->length == 0) {
common_log(LOG_ERR, __METHOD__ . ": no entries in feed update, ignoring");
......@@ -405,6 +411,26 @@ class Ostatus_profile extends Memcached_DataObject
}
}
public function processRssFeed(DOMElement $rss, $source)
{
$channels = $rss->getElementsByTagName('channel');
if ($channels->length == 0) {
throw new Exception("RSS feed without a channel.");
} else if ($channels->length > 1) {
common_log(LOG_WARNING, __METHOD__ . ": more than one channel in an RSS feed");
}
$channel = $channels->item(0);
$items = $channel->getElementsByTagName('item');
for ($i = 0; $i < $items->length; $i++) {
$item = $items->item($i);
$this->processEntry($item, $channel, $source);
}
}
/**
* Process a posted entry from this feed source.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment