]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/atomnoticefeed.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / lib / atomnoticefeed.php
index ef44de4b6ce615bdafe4fc7e34f315ed06bceb01..b7e1ed1b41c1178cb8b1ff1f44c4b670f3f06f19 100644 (file)
@@ -45,6 +45,7 @@ if (!defined('STATUSNET'))
 class AtomNoticeFeed extends Atom10Feed
 {
     var $cur;
+    protected $scoped=null;
 
     /**
      * Constructor - adds a bunch of XML namespaces we need in our
@@ -58,7 +59,8 @@ class AtomNoticeFeed extends Atom10Feed
     function __construct($cur = null, $indent = true) {
         parent::__construct($indent);
 
-        $this->cur = $cur;
+        $this->cur = $cur ?: common_current_user();
+        $this->scoped = !is_null($this->cur) ? $this->cur->getProfile() : null;
 
         // Feeds containing notice info use these namespaces
 
@@ -95,7 +97,7 @@ class AtomNoticeFeed extends Atom10Feed
 
         $this->addNamespace(
             'statusnet',
-            'http://status.net/ont/'
+            'http://status.net/schema/api/1/'
         );
     }
 
@@ -111,10 +113,12 @@ class AtomNoticeFeed extends Atom10Feed
             foreach ($notices as $notice) {
                 $this->addEntryFromNotice($notice);
             }
-        } else {
+        } elseif ($notices instanceof Notice) {
             while ($notices->fetch()) {
                 $this->addEntryFromNotice($notices);
             }
+        } else {
+            throw new ServerException('addEntryFromNotices got neither an array nor a Notice object');
         }
     }
 
@@ -123,14 +127,17 @@ class AtomNoticeFeed extends Atom10Feed
      *
      * @param Notice $notice a Notice to add
      */
-    function addEntryFromNotice($notice)
+    function addEntryFromNotice(Notice $notice)
     {
-        $source = $this->showSource();
-        $author = $this->showAuthor();
-
-        $cur = empty($this->cur) ? common_current_user() : $this->cur;
-
-        $this->addEntryRaw($notice->asAtomEntry(false, $source, $author, $cur));
+        try {
+            $source = $this->showSource();
+            $author = $this->showAuthor();
+
+            $this->addEntryRaw($notice->asAtomEntry(false, $source, $author, $this->scoped));
+        } catch (Exception $e) {
+            common_log(LOG_ERR, $e->getMessage());
+            // we continue on exceptions
+        }
     }
 
     function showSource()