X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=actions%2Fapiblockcreate.php;h=c26485f591b23196917eb07f3fcc8b65e6ab72d3;hb=ddb656fcd2a3233b26e28987d2f3425944908d30;hp=4f941f6c32e3a8f10b0f4d6c82454919ff59c26b;hpb=104a47e4a2903f1c7ea73363a73cee12f0cf14ac;p=quix0rs-gnu-social.git diff --git a/actions/apiblockcreate.php b/actions/apiblockcreate.php index 4f941f6c32..c26485f591 100644 --- a/actions/apiblockcreate.php +++ b/actions/apiblockcreate.php @@ -98,9 +98,27 @@ class ApiBlockCreateAction extends ApiAuthAction 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);