]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Hide posts from users with private_stream in scoping streams
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 24 Feb 2015 21:59:58 +0000 (22:59 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Tue, 24 Feb 2015 21:59:58 +0000 (22:59 +0100)
For example the public timeline would show notices from a user with
private_stream configured. (previously it would only hide _new_ notices
by this user as they would be the only ones with notice scoping set).

classes/Notice.php
classes/Profile.php
classes/User.php

index 81a4d8d2e5e972d9001016bf1c3afcafd3293959..c631c1fcc6768dd690bb449c8115096c1806f644 100644 (file)
@@ -2676,7 +2676,7 @@ class Notice extends Managed_DataObject
             $scope = self::defaultScope();
         }
 
-        if ($scope == 0) { // Not scoping, so it is public.
+        if ($scope == 0 && !$this->getProfile()->isPrivateStream()) { // Not scoping, so it is public.
             return !$this->isHiddenSpam($profile);
         }
 
@@ -2727,18 +2727,9 @@ class Notice extends Managed_DataObject
             }
         }
 
-        // Only for followers of the author
-        $author = null;
+        if ($scope & Notice::FOLLOWER_SCOPE || $this->getProfile()->isPrivateStream()) {
 
-        if ($scope & Notice::FOLLOWER_SCOPE) {
-
-            try {
-                $author = $this->getProfile();
-            } catch (Exception $e) {
-                return false;
-            }
-
-            if (!Subscription::exists($profile, $author)) {
+            if (!Subscription::exists($profile, $this->getProfile())) {
                 return false;
             }
         }
index 3c3b3475b955988386b566bef7853ed33371ba9a..a944d5b4d23f5768c6d4ffcd4ade2b21b61b79a8 100644 (file)
@@ -1572,6 +1572,15 @@ class Profile extends Managed_DataObject
         return $this->getUser()->shortenLinks($text, $always);
     }
 
+    public function isPrivateStream()
+    {
+        // We only know of public remote users as of yet...
+        if (!$this->isLocal()) {
+            return false;
+        }
+        return $this->getUser()->private_stream ? true : false;
+    }
+
     public function delPref($namespace, $topic) {
         return Profile_prefs::setData($this, $namespace, $topic, null);
     }
index c7c91c8ec602bc2da65ed1cd12932f449325b860..764574d2254d7765d44ada464eb486ed4d5d5500 100644 (file)
@@ -992,6 +992,11 @@ class User extends Managed_DataObject
         return $act;
     }
 
+    public function isPrivateStream()
+    {
+        return $this->getProfile()->isPrivateStream();
+    }
+
     public function delPref($namespace, $topic)
     {
         return $this->getProfile()->delPref($namespace, $topic);