/** * Deletes message by ID. * Images connected to the message (WordPress Media Library attachments) are also deleted. * * @param integer $id * * @return null */ public function deleteById($id) { if ($this->messagesDAO->get($id) !== null) { $this->messagesDAO->deleteById($id); $this->attachmentsService->deleteAttachmentsByMessageIds(array($id)); } }
/** * Bans an user by message ID. * * @param integer $messageId * @param WiseChatChannel $channel * @param string $durationString * * @throws Exception If the message or user was not found */ public function banByMessageId($messageId, $channel, $durationString = '1d') { $message = $this->messagesDAO->get($messageId); if ($message === null) { throw new Exception('Message was not found'); } $channelUser = $this->channelUsersDAO->getByUserIdAndChannelId($message->getUserId(), $channel->getId()); if ($channelUser !== null) { $user = $this->usersDAO->get($message->getUserId()); if ($user !== null) { $duration = $this->getDurationFromString($durationString); $this->banIpAddress($user->getIp(), $duration); return; } } throw new Exception('User was not found in this channel'); }