feat(backend): return short IDs
This commit is contained in:
parent
e7e4937082
commit
e76c634738
2 changed files with 9 additions and 5 deletions
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue