diff --git a/SlackNet.Tests/Objects/UserTests.cs b/SlackNet.Tests/Objects/UserTests.cs index f00a65c6..058ff954 100644 --- a/SlackNet.Tests/Objects/UserTests.cs +++ b/SlackNet.Tests/Objects/UserTests.cs @@ -34,4 +34,55 @@ public void Serialization_WorksCorrectlyForAvatarFields() "https://secure.gravatar.com/avatar/invalid.jpg?s=24\u0026d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0008-24.png"); } + + [Test] + public void Serialization_WorksCorrectlyForIsEmailConfirmed() + { + var settings = Default.JsonSettings(Default.SlackTypeResolver(Default.AssembliesContainingSlackTypes)).SerializerSettings; + + var user = JsonConvert.DeserializeObject(@"{ ""id"": ""U12345678"", ""is_email_confirmed"": true }", settings); + + user.IsEmailConfirmed.ShouldBe(true); + } + + [Test] + public void Serialization_WorksCorrectlyForWhoCanShareContactCard() + { + var settings = Default.JsonSettings(Default.SlackTypeResolver(Default.AssembliesContainingSlackTypes)).SerializerSettings; + + var user = JsonConvert.DeserializeObject(@"{ ""id"": ""U12345678"", ""who_can_share_contact_card"": ""EVERYONE"" }", settings); + + user.WhoCanShareContactCard.ShouldBe("EVERYONE"); + } + + [Test] + public void Serialization_WorksCorrectlyForIsWorkflowBot() + { + var settings = Default.JsonSettings(Default.SlackTypeResolver(Default.AssembliesContainingSlackTypes)).SerializerSettings; + + var user = JsonConvert.DeserializeObject(@"{ ""id"": ""B12345678"", ""is_bot"": true, ""is_workflow_bot"": true }", settings); + + user.IsWorkflowBot.ShouldBe(true); + } + + [Test] + public void Serialization_WorksCorrectlyForDisplayNameNormalized() + { + var settings = Default.JsonSettings(Default.SlackTypeResolver(Default.AssembliesContainingSlackTypes)).SerializerSettings; + + var user = JsonConvert.DeserializeObject(@"{ ""id"": ""U12345678"", ""profile"": { ""display_name"": ""Zo\u00eb"", ""display_name_normalized"": ""Zo"" } }", settings); + + user.Profile.DisplayNameNormalized.ShouldBe("Zo"); + } + + [Test] + public void Serialization_WorksCorrectlyForImage1024AndIsCustomImage() + { + var settings = Default.JsonSettings(Default.SlackTypeResolver(Default.AssembliesContainingSlackTypes)).SerializerSettings; + + var user = JsonConvert.DeserializeObject(@"{ ""id"": ""U12345678"", ""profile"": { ""image_1024"": ""https://avatars.slack-edge.com/profile_1024.png"", ""is_custom_image"": true } }", settings); + + user.Profile.Image1024.ShouldBe("https://avatars.slack-edge.com/profile_1024.png"); + user.Profile.IsCustomImage.ShouldBe(true); + } } \ No newline at end of file diff --git a/SlackNet/Objects/User.cs b/SlackNet/Objects/User.cs index 3282b94b..a4e0a116 100644 --- a/SlackNet/Objects/User.cs +++ b/SlackNet/Objects/User.cs @@ -21,10 +21,14 @@ public class User public bool IsRestricted { get; set; } public bool IsUltraRestricted { get; set; } public bool IsBot { get; set; } + /// Whether this is a workflow bot user. + public bool IsWorkflowBot { get; set; } public bool IsStranger { get; set; } public int Updated { get; set; } public bool IsAppUser { get; set; } public bool IsInvitedUser { get; set; } + /// Whether the user's email address has been confirmed. + public bool IsEmailConfirmed { get; set; } [JsonIgnore] public DateTime UpdateTime => Updated.ToDateTime().GetValueOrDefault(); [JsonProperty("has_2fa")] @@ -32,6 +36,8 @@ public class User public string TwoFactorType { get; set; } public string Locale { get; set; } public EnterpriseUser EnterpriseUser { get; set; } + /// Contact card sharing permission setting. + public string WhoCanShareContactCard { get; set; } public override string ToString() => Link.User(Id).ToString(); } \ No newline at end of file diff --git a/SlackNet/Objects/UserProfile.cs b/SlackNet/Objects/UserProfile.cs index 96835253..f1f349f3 100644 --- a/SlackNet/Objects/UserProfile.cs +++ b/SlackNet/Objects/UserProfile.cs @@ -18,6 +18,8 @@ public class UserProfile public string RealName { get; set; } public string RealNameNormalized { get; set; } public string DisplayName { get; set; } + /// The field, but with any non-Latin characters filtered out. + public string DisplayNameNormalized { get; set; } public string Pronouns { get; set; } public string Email { get; set; } public string HuddleState { get; set; } @@ -40,6 +42,11 @@ public class UserProfile public string Image192 { get; set; } [JsonProperty("image_512")] public string Image512 { get; set; } + /// 1024px profile image URL. + [JsonProperty("image_1024")] + public string Image1024 { get; set; } + /// Whether the user uploaded a custom profile image. + public bool IsCustomImage { get; set; } [JsonConverter(typeof(IgnoreArrayConverter))] // Slack returns an empty array instead of an object if profile has been modified, but no custom fields have been set public IDictionary Fields { get; set; } = new Dictionary(); } \ No newline at end of file