/**
  * @ApiDoc(
  *  resource = true,
  *  description = "Post a new message NEED X-AUTH-TOKEN",
  *  statusCodes = {
  *      200 = "Returned when successful",
  *      403 = "Returned when forbidden"
  *  }
  * )
  *
  * @param ParamFetcher $paramFetcher
  * @param Request      $request
  *
  * @return View
  *
  * @throws \HttpInvalidParamException
  *
  * @RequestParam(name="to", nullable=true, description="Message receiver")
  * @RequestParam(name="text", nullable=true, description="Message content")
  * @RequestParam(name="type", nullable=true, description="Message type")
  * @RequestParam(name="conversationId", nullable=true, description="Id the of conversation")
  */
 public function postAction(ParamFetcher $paramFetcher, Request $request)
 {
     $em = $this->getManager();
     $from = LoginApiController::checkAuthentication($request, $em);
     $message = new Message();
     // Conversation
     $conversation = $this->handleConversation($from, $paramFetcher);
     $message->setConversation($conversation);
     // Type
     $message = $this->handleMessageType($message, $paramFetcher->get('type'));
     // Text
     $message->setText($paramFetcher->get('text'));
     // User
     $message->setUser($from);
     $em->persist($message);
     $em->persist($conversation);
     $em->flush();
     // Don't return the whole message with useless and/or confidential informations
     // Just fill a ValueObject
     $messageValueObject = $this->populateMessageValueObject($message, $from);
     return $this->view($messageValueObject);
 }