]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/profilenoticestream.php
If there's no Happening, we can't use the RSVP.
[quix0rs-gnu-social.git] / lib / profilenoticestream.php
index cd89769ec27a7769926fb0e8d9f5db420f70a5c4..3c8de05855bb014eeade3f4f7708d137075be186 100644 (file)
@@ -62,7 +62,7 @@ class ProfileNoticeStream extends ScopingNoticeStream
                             $userProfile);
     }
 
-    function getNoticeIds($offset, $limit, $since_id, $max_id)
+    function getNoticeIds($offset, $limit, $since_id=null, $max_id=null)
     {
         if ($this->impossibleStream()) {
             return array();
@@ -71,23 +71,19 @@ class ProfileNoticeStream extends ScopingNoticeStream
         }
     }
 
-    function getNotices($offset, $limit, $sinceId = null, $maxId = null)
+    function getNotices($offset, $limit, $since_id=null, $max_id=null)
     {
         if ($this->impossibleStream()) {
-            return array();
+            throw new PrivateStreamException($this->streamProfile, $this->userProfile);
         } else {
-            return parent::getNotices($offset, $limit, $sinceId, $maxId);
+            return parent::getNotices($offset, $limit, $since_id, $max_id);
         }
     }
 
     function impossibleStream() 
     {
-        $user = User::staticGet('id', $this->streamProfile->id);
-
-        // If it's a private stream, and no user or not a subscriber
-
-        if (!empty($user) && $user->private_stream && 
-            (empty($this->userProfile) || !$this->userProfile->isSubscribed($this->streamProfile))) {
+        if (!$this->streamProfile->readableBy($this->userProfile)) {
+            // cannot read because it's a private stream and either noone's logged in or they are not subscribers
             return true;
         }
 
@@ -95,7 +91,7 @@ class ProfileNoticeStream extends ScopingNoticeStream
 
         if (common_config('notice', 'hidespam')) {
             if ($this->streamProfile->hasRole(Profile_role::SILENCED) &&
-                (empty($this->userProfile) || !$this->userProfile->hasRole(Profile_role::MODERATOR))) {
+                (empty($this->userProfile) || (($this->userProfile->id !== $this->streamProfile->id) && !$this->userProfile->hasRight(Right::REVIEWSPAM)))) {
                 return true;
             }
         }
@@ -121,6 +117,7 @@ class RawProfileNoticeStream extends NoticeStream
 
     function __construct($profile)
     {
+        parent::__construct();
         $this->profile = $profile;
     }