]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apiblockcreate.php
Initial upgraded Atom output for group timelines
[quix0rs-gnu-social.git] / actions / apiblockcreate.php
index 1cab2df5d0d9584ebf9d982aa69eb0dc1ccb622d..c26485f591b23196917eb07f3fcc8b65e6ab72d3 100644 (file)
@@ -94,13 +94,31 @@ class ApiBlockCreateAction extends ApiAuthAction
         }
 
         if (empty($this->user) || empty($this->other)) {
-            $this->clientError(_('No such user!'), 404, $this->format);
+            $this->clientError(_('No such user.'), 404, $this->format);
             return;
         }
 
-        if ($this->user->hasBlocked($this->other)
-            || $this->user->block($this->other)
-        ) {
+        // Don't allow blocking yourself!
+
+        if ($this->user->id == $this->other->id) {
+            $this->clientError(
+                _("You cannot block yourself!"),
+                403,
+                $this->format
+            );
+            return;
+        }
+
+        if (!$this->user->hasBlocked($this->other)) {
+            if (Event::handle('StartBlockProfile', array($this->user, $this->other))) {
+                $result = $this->user->block($this->other);
+                if ($result) {
+                    Event::handle('EndBlockProfile', array($this->user, $this->other));
+                }
+            }
+        }
+
+        if ($this->user->hasBlocked($this->other)) {
             $this->initDocument($this->format);
             $this->showProfile($this->other, $this->format);
             $this->endDocument($this->format);