]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile.php
If a user has a private stream, assume a moderated subscription policy
[quix0rs-gnu-social.git] / classes / Profile.php
index 1c8dbcc2525e14b45c7de055fde0844535f9dfb2..f4452391c25819dadb930e08d7d2c9eb1d93db64 100644 (file)
@@ -772,6 +772,25 @@ class Profile extends Managed_DataObject
         return is_null($other) ? false : $other->isSubscribed($this);
     }
 
+    function requiresSubscriptionApproval(Profile $other=null)
+    {
+        if (!$this->isLocal()) {
+            // We don't know for remote users, and we'll always be able to send
+            // the request. Whether it'll work immediately or require moderation
+            // can be determined in another function.
+            return false;
+        }
+
+        // Assume that profiles _we_ subscribe to are permitted. Could be made configurable.
+        if (!is_null($other) && $this->isSubscribed($other)) {
+            return false;
+        }
+
+        // If the local user either has a private stream (implies the following)
+        // or  user has a moderation policy for new subscriptions, return true.
+        return $this->getUser()->private_stream || $this->getUser()->subscribe_policy === User::SUBSCRIBE_POLICY_MODERATE;
+    }
+
     /**
      * Check if a pending subscription request is outstanding for this...
      *