From e76c634738afe40b8ac830f77907e53e894c59e2 Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 26 Sep 2024 15:26:52 +0200 Subject: [PATCH] feat(backend): return short IDs --- Foxnouns.Backend/Services/MemberRendererService.cs | 8 +++++--- Foxnouns.Backend/Services/UserRendererService.cs | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Foxnouns.Backend/Services/MemberRendererService.cs b/Foxnouns.Backend/Services/MemberRendererService.cs index ef7b923..625e8b8 100644 --- a/Foxnouns.Backend/Services/MemberRendererService.cs +++ b/Foxnouns.Backend/Services/MemberRendererService.cs @@ -29,15 +29,15 @@ public class MemberRendererService(DatabaseContext db, Config config) var renderUnlisted = token?.UserId == member.UserId && token.HasScope("user.read_hidden"); return new MemberResponse( - member.Id, member.Name, member.DisplayName, member.Bio, + member.Id, member.Sid, member.Name, member.DisplayName, member.Bio, AvatarUrlFor(member), member.Links, member.Names, member.Pronouns, member.Fields, RenderPartialUser(member.User), renderUnlisted ? member.Unlisted : null); } private UserRendererService.PartialUser RenderPartialUser(User user) => - new(user.Id, user.Username, user.DisplayName, AvatarUrlFor(user), user.CustomPreferences); + new(user.Id, user.Sid, user.Username, user.DisplayName, AvatarUrlFor(user), user.CustomPreferences); - public PartialMember RenderPartialMember(Member member, bool renderUnlisted = false) => new(member.Id, member.Name, + public PartialMember RenderPartialMember(Member member, bool renderUnlisted = false) => new(member.Id, member.Sid, member.Name, member.DisplayName, member.Bio, AvatarUrlFor(member), member.Names, member.Pronouns, renderUnlisted ? member.Unlisted : null); @@ -49,6 +49,7 @@ public class MemberRendererService(DatabaseContext db, Config config) public record PartialMember( Snowflake Id, + string Sid, string Name, string? DisplayName, string? Bio, @@ -60,6 +61,7 @@ public class MemberRendererService(DatabaseContext db, Config config) public record MemberResponse( Snowflake Id, + string Sid, string Name, string? DisplayName, string? Bio, diff --git a/Foxnouns.Backend/Services/UserRendererService.cs b/Foxnouns.Backend/Services/UserRendererService.cs index dd266fa..5a62a1a 100644 --- a/Foxnouns.Backend/Services/UserRendererService.cs +++ b/Foxnouns.Backend/Services/UserRendererService.cs @@ -37,7 +37,7 @@ public class UserRendererService(DatabaseContext db, MemberRendererService membe : []; return new UserResponse( - user.Id, user.Username, user.DisplayName, user.Bio, user.MemberTitle, AvatarUrlFor(user), user.Links, + user.Id, user.Sid, user.Username, user.DisplayName, user.Bio, user.MemberTitle, AvatarUrlFor(user), user.Links, user.Names, user.Pronouns, user.Fields, user.CustomPreferences, renderMembers ? members.Select(m => memberRenderer.RenderPartialMember(m, tokenHidden)) : null, renderAuthMethods @@ -52,13 +52,14 @@ public class UserRendererService(DatabaseContext db, MemberRendererService membe } public PartialUser RenderPartialUser(User user) => - new(user.Id, user.Username, user.DisplayName, AvatarUrlFor(user), user.CustomPreferences); + new(user.Id, user.Sid, user.Username, user.DisplayName, AvatarUrlFor(user), user.CustomPreferences); private string? AvatarUrlFor(User user) => user.Avatar != null ? $"{config.MediaBaseUrl}/users/{user.Id}/avatars/{user.Avatar}.webp" : null; public record UserResponse( Snowflake Id, + string Sid, string Username, string? DisplayName, string? Bio, @@ -92,6 +93,7 @@ public class UserRendererService(DatabaseContext db, MemberRendererService membe public record PartialUser( Snowflake Id, + string Sid, string Username, string? DisplayName, string? AvatarUrl,