diff --git a/Foxnouns.Backend/Database/DatabaseQueryExtensions.cs b/Foxnouns.Backend/Database/DatabaseQueryExtensions.cs index 60d4499..d5df79d 100644 --- a/Foxnouns.Backend/Database/DatabaseQueryExtensions.cs +++ b/Foxnouns.Backend/Database/DatabaseQueryExtensions.cs @@ -71,6 +71,7 @@ public static class DatabaseQueryExtensions { member = await context.Members .Include(m => m.User) + .Include(m => m.ProfileFlags) .Where(m => !m.User.Deleted) .FirstOrDefaultAsync(m => m.Id == snowflake && m.UserId == userId, ct); if (member != null) return member; @@ -78,6 +79,7 @@ public static class DatabaseQueryExtensions member = await context.Members .Include(m => m.User) + .Include(m => m.ProfileFlags) .Where(m => !m.User.Deleted) .FirstOrDefaultAsync(m => m.Name == memberRef && m.UserId == userId, ct); if (member != null) return member; diff --git a/Foxnouns.Backend/Middleware/ErrorHandlerMiddleware.cs b/Foxnouns.Backend/Middleware/ErrorHandlerMiddleware.cs index 6b6da6d..c28b58e 100644 --- a/Foxnouns.Backend/Middleware/ErrorHandlerMiddleware.cs +++ b/Foxnouns.Backend/Middleware/ErrorHandlerMiddleware.cs @@ -1,5 +1,6 @@ using System.Net; using Foxnouns.Backend.Utils; +using Microsoft.AspNetCore.Mvc.ModelBinding; using Newtonsoft.Json; namespace Foxnouns.Backend.Middleware; diff --git a/Foxnouns.Backend/Services/MemberRendererService.cs b/Foxnouns.Backend/Services/MemberRendererService.cs index 0fdaa53..9ebea49 100644 --- a/Foxnouns.Backend/Services/MemberRendererService.cs +++ b/Foxnouns.Backend/Services/MemberRendererService.cs @@ -24,13 +24,14 @@ public class MemberRendererService(DatabaseContext db, Config config) return members.Select(m => RenderPartialMember(m, renderUnlisted)); } - public MemberResponse RenderMember(Member member, Token? token) + public MemberResponse RenderMember(Member member, Token? token = null) { var renderUnlisted = token?.UserId == member.UserId && token.HasScope("user.read_hidden"); return new MemberResponse( member.Id, member.Sid, member.Name, member.DisplayName, member.Bio, AvatarUrlFor(member), member.Links, member.Names, member.Pronouns, member.Fields, + member.ProfileFlags.Select(f => RenderPrideFlag(f.PrideFlag)), RenderPartialUser(member.User), renderUnlisted ? member.Unlisted : null); } @@ -50,6 +51,9 @@ public class MemberRendererService(DatabaseContext db, Config config) private string ImageUrlFor(PrideFlag flag) => $"{config.MediaBaseUrl}/flags/{flag.Hash}.webp"; + private UserRendererService.PrideFlagResponse RenderPrideFlag(PrideFlag flag) => + new(flag.Id, ImageUrlFor(flag), flag.Name, flag.Description); + public record PartialMember( Snowflake Id, string Sid, @@ -73,6 +77,7 @@ public class MemberRendererService(DatabaseContext db, Config config) IEnumerable Names, IEnumerable Pronouns, IEnumerable Fields, + IEnumerable Flags, UserRendererService.PartialUser User, [property: JsonProperty(NullValueHandling = NullValueHandling.Ignore)] bool? Unlisted);