]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
ensure from an RSS channel
authorEvan Prodromou <evan@status.net>
Fri, 19 Mar 2010 20:50:06 +0000 (15:50 -0500)
committerEvan Prodromou <evan@status.net>
Fri, 19 Mar 2010 20:50:06 +0000 (15:50 -0500)
plugins/OStatus/classes/Ostatus_profile.php

index e0e0223b8f950cd4382104790b1f489a54cd910a..80b980aba4dac360156c6ed36698993e9bc6b43b 100644 (file)
@@ -788,9 +788,20 @@ class Ostatus_profile extends Memcached_DataObject
             throw new FeedSubNoHubException();
         }
 
-        // Try to get a profile from the feed activity:subject
+        $feedEl = $discover->root;
+
+        if ($feedEl->tagName == 'feed') {
+            return self::ensureAtomFeed($feedEl, $hints);
+        } else if ($feedEl->tagName == 'channel') {
+            return self::ensureRssChannel($feedEl, $hints);
+        } else {
+            throw new FeedSubBadXmlException($feeduri);
+        }
+    }
 
-        $feedEl = $discover->feed->documentElement;
+    public static function ensureAtomFeed($feedEl, $hints)
+    {
+        // Try to get a profile from the feed activity:subject
 
         $subject = ActivityUtils::child($feedEl, Activity::SUBJECT, Activity::SPEC);
 
@@ -838,6 +849,17 @@ class Ostatus_profile extends Memcached_DataObject
         throw new FeedSubException("Can't find enough profile information to make a feed.");
     }
 
+    public static function ensureRssChannel($feedEl, $hints)
+    {
+        // @fixme we should check whether this feed has elements
+        // with different <author> or <dc:creator> elements, and... I dunno.
+        // Do something about that.
+
+        $obj = ActivityObject::fromRssChannel($feedEl);
+
+        return self::ensureActivityObjectProfile($obj, $hints);
+    }
+
     /**
      * Download and update given avatar image
      *