From ce91f1c0e6a001c1e43ee52dfd26789ac4f83d45 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Tue, 24 Feb 2015 22:59:58 +0100 Subject: [PATCH] Hide posts from users with private_stream in scoping streams 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 | 15 +++------------ classes/Profile.php | 9 +++++++++ classes/User.php | 5 +++++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 81a4d8d2e5..c631c1fcc6 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -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; } } diff --git a/classes/Profile.php b/classes/Profile.php index 3c3b3475b9..a944d5b4d2 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -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); } diff --git a/classes/User.php b/classes/User.php index c7c91c8ec6..764574d225 100644 --- a/classes/User.php +++ b/classes/User.php @@ -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); -- 2.39.5