summaryrefslogtreecommitdiff
path: root/plugins/OStatus
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/OStatus')
-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.
*