3 if (!defined('GNUSOCIAL')) { exit(1); }
6 * Moderated notice stream, will take into account the scoping of
7 * notices as well as whether the profile is moderated somehow,
8 * such as by sandboxing or silencing.
10 * Inherits $this->scoped from ScopingNoticeStream as the Profile
11 * this stream is meant for. Can be null in case we're not logged in.
15 * @author Mikael Nordfeldth <mmn@hethane.se>
16 * @copyright 2016 Free Software Foundation, Inc.
17 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
18 * @link https://gnu.io/social
21 class ModeratedNoticeStream extends ScopingNoticeStream
23 protected function filter(Notice $notice)
25 if (!parent::filter($notice)) {
29 if(self::include_or_not($notice) === false) {
33 // If this is a repeat the repeated notice is moderated
34 if($notice->isRepeat()) {
36 $repeated_notice = Notice::getById($notice->repeat_of);
37 } catch (Exception $e) {
38 // if we can't get the repeated notice by id, something is seriously wrong with it, so don't include it
42 if(self::include_or_not($repeated_notice) === false) {
50 protected function include_or_not(Notice $notice)
52 $profile = $notice->getProfile();
54 if ($profile->isSandboxed()) {
55 if (!$this->scoped instanceof Profile) {
56 // Non-logged in users don't get to see posts by sandboxed users
58 } elseif (!$profile->sameAs($this->scoped) && !$this->scoped->hasRight(Right::REVIEWSPAM)) {
59 // And if we are logged in, deny if scoped user is neither the author nor has the right to review spam