/** * Endpoint for banning users by message ID. */ public function userBanEndpoint() { $this->verifyCheckSum(); $response = array(); try { $this->checkChatOpen(); $this->checkUserAuthentication(); $this->checkUserRight('ban_user'); $this->checkPostParams(array('channelId', 'messageId')); $channelId = trim($this->getPostParam('channelId')); $messageId = trim($this->getPostParam('messageId')); $channel = $this->channelsDAO->get($channelId); $this->checkChannel($channel); $this->checkChannelAuthorization($channel); $duration = $this->options->getIntegerOption('moderation_ban_duration', 1440); $this->bansService->banByMessageId($messageId, $channel, $duration . 'm'); $this->messagesService->addMessage($this->authentication->getSystemUser(), $channel, "User has been banned for {$duration} minutes", true); $response['result'] = 'OK'; } catch (WiseChatUnauthorizedAccessException $exception) { $response['error'] = $exception->getMessage(); $this->sendUnauthorizedStatus(); } catch (Exception $exception) { $response['error'] = $exception->getMessage(); $this->sendBadRequestStatus(); } echo json_encode($response); die; }
protected function addMessage($message) { $this->messagesService->addMessage($this->authentication->getSystemUser(), $this->channel, $message, true); }