public ActionResult <ChatInfoUser> GetWithChatDetails([FromQuery] Guid userId) { if (userId.Equals(Guid.Empty)) { return(BadRequest()); } var userEntity = _userService.GetUser(userId); if (userEntity == null) { return(StatusCode(404)); } ChatInfoUser returnUser = new ChatInfoUser(); returnUser.MapUserEntityToBaseUser(userEntity); returnUser.ChatUserDetails = new List <ChatUser>(); userEntity.ChatIntegrations?.ForEach(x => { _clientDictionary.TryGetValue(x.IntegrationId, out var client); if (client != null) { BaseUserResponse response = client.GetUserInfo(x).Result; if (response != null) { var transformedResponse = response.CreateDerivedUserInfoFromBaseResponse(x); returnUser.ChatUserDetails.Add(transformedResponse); } ; } }); return(returnUser); }
public static ChatUser CreateDerivedUserInfoFromBaseResponse(this BaseUserResponse response, ChatIntegrationEntity integrationEntity) { if (integrationEntity.IntegrationId.IsSlackIntegration()) { var slackUserResponse = (response as UserResponse); if (slackUserResponse.IsOk) { var userInfo = slackUserResponse.UserInfo; return(new SlackUser { Id = userInfo.Id, TeamId = userInfo.TeamId, UserName = userInfo.Name, Deleted = userInfo.Deleted, Color = userInfo.Color, RealName = userInfo.RealName, TimeZone = userInfo.TimeZone, TimeZoneLabel = userInfo.TimeZoneLabel, TimeZoneOffset = userInfo.TimeZoneOffset, IsAdmin = userInfo.IsAdmin, IsOwner = userInfo.IsOwner, IsPrimaryOwner = userInfo.IsPrimaryOwner, IsRestricted = userInfo.IsRestricted, IsUltraRestricted = userInfo.IsUltraRestricted, IsBot = userInfo.IsBot, Updated = userInfo.Updated, IsAppUser = userInfo.IsAppUser, Has2FA = userInfo.Has2FA, Profile = new Contracts.ViewModels.Slack.Profile { AvatarHash = userInfo.Profile.AvatarHash, StatusText = userInfo.Profile.StatusText, StatusEmoji = userInfo.Profile.StatusEmoji, RealName = userInfo.Profile.RealName, DisplayName = userInfo.Profile.DisplayName, RealNameNormalized = userInfo.Profile.RealNameNormalized, DisplayNameNormalized = userInfo.Profile.DisplayNameNormalized, Email = userInfo.Profile.Email, ImageOriginal = userInfo.Profile.ImageOriginal, Image24 = userInfo.Profile.Image24, Image32 = userInfo.Profile.Image32, Image48 = userInfo.Profile.Image48, Image72 = userInfo.Profile.Image72, Image192 = userInfo.Profile.Image192, Image512 = userInfo.Profile.Image512, Team = userInfo.Profile.Team } }); } } return(new ChatUser()); }