From 976f1d9d7062aaedca52cdd6398576b717b5f58f Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 8 Aug 2020 15:35:36 +0800 Subject: Add user unique id. --- Timeline.Tests/IntegratedTests/UserTest.cs | 9 +++++++++ Timeline/Models/Http/UserInfo.cs | 1 + Timeline/Models/User.cs | 1 + Timeline/Services/UserService.cs | 1 + 4 files changed, 12 insertions(+) diff --git a/Timeline.Tests/IntegratedTests/UserTest.cs b/Timeline.Tests/IntegratedTests/UserTest.cs index 7fd78d0e..9dfcc6a5 100644 --- a/Timeline.Tests/IntegratedTests/UserTest.cs +++ b/Timeline.Tests/IntegratedTests/UserTest.cs @@ -11,6 +11,15 @@ namespace Timeline.Tests.IntegratedTests { public class UserTest : IntegratedTestBase { + [Fact] + public void UserListShouldHaveUniqueId() + { + foreach (var user in UserInfos) + { + user.UniqueId.Should().NotBeNullOrWhiteSpace(); + } + } + [Fact] public async Task GetList_NoAuth() { diff --git a/Timeline/Models/Http/UserInfo.cs b/Timeline/Models/Http/UserInfo.cs index 0acb1a80..c9a26072 100644 --- a/Timeline/Models/Http/UserInfo.cs +++ b/Timeline/Models/Http/UserInfo.cs @@ -9,6 +9,7 @@ namespace Timeline.Models.Http { public class UserInfo { + public string UniqueId { get; set; } = default!; public string Username { get; set; } = default!; public string Nickname { get; set; } = default!; public bool? Administrator { get; set; } = default!; diff --git a/Timeline/Models/User.cs b/Timeline/Models/User.cs index 37777eba..fa780efd 100644 --- a/Timeline/Models/User.cs +++ b/Timeline/Models/User.cs @@ -2,6 +2,7 @@ { public class User { + public string? UniqueId { get; set; } public string? Username { get; set; } public string? Nickname { get; set; } diff --git a/Timeline/Services/UserService.cs b/Timeline/Services/UserService.cs index c20b180c..91d27965 100644 --- a/Timeline/Services/UserService.cs +++ b/Timeline/Services/UserService.cs @@ -205,6 +205,7 @@ namespace Timeline.Services { return new User { + UniqueId = entity.UniqueId, Username = entity.Username, Administrator = UserRoleConvert.ToBool(entity.Roles), Nickname = string.IsNullOrEmpty(entity.Nickname) ? entity.Username : entity.Nickname, -- cgit v1.2.3