/** * Publishes a message with given attachments in the given channel. * * @param WiseChatUser $user Author of the message * @param WiseChatChannel $channel A channel to publish in * @param string $text Content of the message * @param array $attachments Array of attachments (only single image is supported) * * @return WiseChatMessage|null Added message * @throws Exception On validation error */ public function addMessageWithAttachments($user, $channel, $text, $attachments) { $message = $this->addMessage($user, $channel, $text); list($attachmentShortcode, $attachmentIds) = $this->saveAttachments($channel, $attachments); $this->attachmentsService->markAttachmentsWithDetails($attachmentIds, $channel->getName(), $message->getId()); $message->setText($message->getText() . $attachmentShortcode); $this->messagesDAO->save($message); return $message; }