handle RSS as well as Atom in Ostatus push hits
This commit is contained in:
parent
65c8dc313c
commit
f558508784
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user