feat: add PATCH request support, expand PATCH /users/@me, serialize enums correctly

This commit is contained in:
sam 2024-07-12 17:12:24 +02:00
parent d6c9345dba
commit e95e0a79ff
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
20 changed files with 427 additions and 48 deletions

View file

@ -3,16 +3,20 @@ using Foxnouns.Backend.Database.Models;
namespace Foxnouns.Backend.Services;
public class MemberRendererService(DatabaseContext db)
public class MemberRendererService(DatabaseContext db, Config config)
{
public PartialMember RenderPartialMember(Member member) => new(member.Id, member.Name,
member.DisplayName, member.Bio, member.Names, member.Pronouns);
member.DisplayName, member.Bio, AvatarUrlFor(member), member.Names, member.Pronouns);
private string? AvatarUrlFor(Member member) =>
member.Avatar != null ? $"{config.MediaBaseUrl}/members/{member.Id}/avatars/{member.Avatar}.webp" : null;
public record PartialMember(
Snowflake Id,
string Name,
string? DisplayName,
string? Bio,
string? AvatarUrl,
IEnumerable<FieldEntry> Names,
IEnumerable<Pronoun> Pronouns);
}