示例#1
0
        public async Task <IActionResult> GetConversations([FromRoute] Guid userId)
        {
            if (!_authService.AuthorizeSelf(Request.Headers["Authorization"], userId))
            {
                return(Unauthorized());
            }

            return(Ok(await _conversationsService.GetConversations(userId)));
        }
        public async Task <IActionResult> GetConversations(string username, string continuationToken, int limit, long lastSeenConversationTime)
        {
            try
            {
                var conversationsResponse = await _conversationsService.GetConversations(username, continuationToken, limit, lastSeenConversationTime);

                return(Ok(conversationsResponse));
            }
            catch (ConversationNotFoundException e)
            {
                _logger.LogError(e, $"No conversations associated to user {username} were found in storage");
                return(NotFound($"No conversations associated to user  {username} were found"));
            }
            catch (StorageErrorException e)
            {
                _logger.LogError(e, $"Failed to retrieve conversations associated to user {username} from storage");
                return(StatusCode(503, "The service is unavailable, please retry in few minutes"));
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Unknown exception occured while retrieving conversations of user {username} from storage");
                return(StatusCode(500, "An internal server error occured, please reachout to support if this error persists"));
            }
        }