public async Task <IActionResult> Get(int chatId) { var chat = await _chatsRepository.FindByIdAsync(chatId); if (chat is null) { return(NotFound(new { Message = "Chat does not exist." })); } //Check if user in http context is in the chat if (!_chatsRepository.IsUserInChat(chat, HttpContext.GetUserId())) { return(Unauthorized(new { Message = "You do not own this chat" })); } return(Ok(chat)); }