]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Make the public streams ModeratedNoticeStream (hide sandboxed users etc.)
authorMikael Nordfeldth <mmn@hethane.se>
Wed, 2 Mar 2016 10:50:50 +0000 (11:50 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Wed, 2 Mar 2016 10:50:50 +0000 (11:50 +0100)
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 [new file with mode: 0644]
lib/networkpublicnoticestream.php
lib/publicnoticestream.php

diff --git a/lib/moderatednoticestream.php b/lib/moderatednoticestream.php
new file mode 100644 (file)
index 0000000..3c778d8
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+/**
+ * Moderated notice stream, will take into account the scoping of
+ * notices as well as whether the profile is moderated somehow,
+ * such as by sandboxing or silencing.
+ *
+ * Inherits $this->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 <mmn@hethane.se>
+ * @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;
+    }
+}
index bd4da5d0751e5ba4c913c5ca043df8a9e436ffa6..c722bd8c1405ddb07bf71717e4eb1c97e2e98187 100644 (file)
@@ -2,7 +2,7 @@
 
 if (!defined('GNUSOCIAL')) { exit(1); } 
 
-class NetworkPublicNoticeStream extends ScopingNoticeStream
+class NetworkPublicNoticeStream extends ModeratedNoticeStream
 {
     function __construct(Profile $scoped=null)
     {
index 1dd59059fd7e357f8ce2c2d1676ec6ea391c44ff..2638292714fda2cc359f773dd556b5f840a4f404 100644 (file)
@@ -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)
     {