/** * @Security("has_role('ROLE_USER')") * @Route("/user/get-conversation/{conv_id}", name="user-get-conversation", options={"expose"=true}) * @param int $conv_id * @return JsonResponse */ public function getConversationAction($conv_id) { /** @var User $user */ $user = $this->getUser(); /** @var EntityManager $em */ $em = $this->getDoctrine()->getManager(); /** @var Conversation $conversation */ $conversation = $em->find('NaidusvoeBundle:Conversation', $conv_id); if ($conversation->getUser1ID() == $user->getId() || $conversation->getUser2ID() == $user->getId()) { $jsonConv = $conversation->getInArray($user); Conversation::setViewed($em, $conversation->getMessages(), $user); $this->get('naidusvoe.notifier')->removeNotifications($user, Notification::CONVERSATION_NOTIFICATION, ['conversation_id' => $conversation->getId()]); return new JsonResponse(['conversation' => $jsonConv, 'user' => $user->getInArray()]); } else { return new JsonResponse(false); } }