From a3b21189068eb980ce27c1a45bcb88734ba11cc4 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 2 Mar 2016 11:50:50 +0100 Subject: [PATCH] Make the public streams ModeratedNoticeStream (hide sandboxed users etc.) Which streams should be put under ModeratedNoticeStream is probably open to debate. But at least the public ones should hide the posts from users that are sandboxed. --- lib/moderatednoticestream.php | 39 +++++++++++++++++++++++++++++++ lib/networkpublicnoticestream.php | 2 +- lib/publicnoticestream.php | 2 +- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 lib/moderatednoticestream.php diff --git a/lib/moderatednoticestream.php b/lib/moderatednoticestream.php new file mode 100644 index 0000000000..3c778d8a2c --- /dev/null +++ b/lib/moderatednoticestream.php @@ -0,0 +1,39 @@ +scoped from ScopingNoticeStream as the Profile + * this stream is meant for. Can be null in case we're not logged in. + * + * @category Stream + * @package GNUsocial + * @author Mikael Nordfeldth + * @copyright 2016 Free Software Foundation, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link https://gnu.io/social + */ + +class ModeratedNoticeStream extends ScopingNoticeStream +{ + protected function filter(Notice $notice) + { + if (!parent::filter($notice)) { + return false; + } + + // If the notice author is sandboxed + if ($notice->getProfile()->isSandboxed()) { + // and we're either not logged in OR we aren't some kind of privileged user that can see spam etc. + if (!$this->scoped instanceof Profile || !$this->scoped->hasRight(Right::REVIEWSPAM)) { + return false; + } + } + + return true; + } +} diff --git a/lib/networkpublicnoticestream.php b/lib/networkpublicnoticestream.php index bd4da5d075..c722bd8c14 100644 --- a/lib/networkpublicnoticestream.php +++ b/lib/networkpublicnoticestream.php @@ -2,7 +2,7 @@ if (!defined('GNUSOCIAL')) { exit(1); } -class NetworkPublicNoticeStream extends ScopingNoticeStream +class NetworkPublicNoticeStream extends ModeratedNoticeStream { function __construct(Profile $scoped=null) { diff --git a/lib/publicnoticestream.php b/lib/publicnoticestream.php index 1dd59059fd..2638292714 100644 --- a/lib/publicnoticestream.php +++ b/lib/publicnoticestream.php @@ -41,7 +41,7 @@ if (!defined('GNUSOCIAL')) { exit(1); } * @link http://status.net/ */ -class PublicNoticeStream extends ScopingNoticeStream +class PublicNoticeStream extends ModeratedNoticeStream { function __construct(Profile $scoped=null) {