summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-03-20 07:23:13 -0500
committerEvan Prodromou <evan@status.net>2010-03-20 07:23:13 -0500
commitf55850878450b27b00bd18b140f2be1357d9713c (patch)
tree4bea417dd962a8865b58fd651e5658088a37902d /plugins
parent65c8dc313c646a4ad4e16bc470b9ac795ca197dd (diff)
handle RSS as well as Atom in Ostatus push hits
Diffstat (limited to 'plugins')
-rw-r--r--plugins/OStatus/classes/Ostatus_profile.php32
1 files changed, 29 insertions, 3 deletions
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php
index 4f449a44d..6885bb953 100644
--- a/plugins/OStatus/classes/Ostatus_profile.php
+++ b/plugins/OStatus/classes/Ostatus_profile.php
@@ -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.
*