2024-05-28 17:09:50 +02:00
|
|
|
using Foxnouns.Backend.Database;
|
|
|
|
using Foxnouns.Backend.Database.Models;
|
|
|
|
|
|
|
|
namespace Foxnouns.Backend.Services;
|
|
|
|
|
2024-07-12 17:12:24 +02:00
|
|
|
public class MemberRendererService(DatabaseContext db, Config config)
|
2024-05-28 17:09:50 +02:00
|
|
|
{
|
|
|
|
public PartialMember RenderPartialMember(Member member) => new(member.Id, member.Name,
|
2024-07-12 17:12:24 +02:00
|
|
|
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;
|
2024-05-28 17:09:50 +02:00
|
|
|
|
|
|
|
public record PartialMember(
|
|
|
|
Snowflake Id,
|
|
|
|
string Name,
|
|
|
|
string? DisplayName,
|
|
|
|
string? Bio,
|
2024-07-12 17:12:24 +02:00
|
|
|
string? AvatarUrl,
|
2024-05-28 17:09:50 +02:00
|
|
|
IEnumerable<FieldEntry> Names,
|
|
|
|
IEnumerable<Pronoun> Pronouns);
|
|
|
|
}
|