From 82a2331ae03d153d8179734b0190adddbb4322b4 Mon Sep 17 00:00:00 2001 From: pancakes Date: Tue, 4 Feb 2025 18:54:24 +1000 Subject: [PATCH] [backend/masto-client] Add avatar_description and header_description to AccountEntity --- .../Controllers/Mastodon/Renderers/UserRenderer.cs | 11 +++++++++++ .../Mastodon/Schemas/Entities/AccountEntity.cs | 3 +++ 2 files changed, 14 insertions(+) diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs index 8bf303d1..8f4790b9 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs @@ -45,6 +45,15 @@ public class UserRenderer( ? profile?.Fields.Select(p => new Field { Name = p.Name, Value = p.Value }).ToList() ?? [] : []; + user.Avatar ??= await db.Users.Where(p => p.Id == user.Id) + .Include(p => p.Avatar) + .Select(p => p.Avatar) + .FirstOrDefaultAsync(); + user.Banner ??= await db.Users.Where(p => p.Id == user.Id) + .Include(p => p.Banner) + .Select(p => p.Banner) + .FirstOrDefaultAsync(); + var res = new AccountEntity { Id = user.Id, @@ -62,8 +71,10 @@ public class UserRenderer( Url = profile?.Url ?? user.Uri ?? user.GetPublicUrl(config.Value), Uri = user.Uri ?? user.GetPublicUri(config.Value), AvatarStaticUrl = user.GetAvatarUrl(config.Value), //TODO + AvatarDescription = user.Avatar?.Comment ?? "", HeaderUrl = user.GetBannerUrl(config.Value) ?? _transparent, HeaderStaticUrl = user.GetBannerUrl(config.Value) ?? _transparent, //TODO + HeaderDescription = user.Banner?.Comment ?? "", MovedToAccount = null, //TODO IsBot = user.IsBot, IsDiscoverable = user.IsExplorable, diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/AccountEntity.cs b/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/AccountEntity.cs index 9b04ae92..44762b4e 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/AccountEntity.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/AccountEntity.cs @@ -28,6 +28,9 @@ public class AccountEntity : IEntity [J("source")] public AccountSource? Source { get; set; } [J("emojis")] public required List Emoji { get; set; } [J("id")] public required string Id { get; set; } + + [J("avatar_description")] public required string AvatarDescription { get; set; } + [J("header_description")] public required string HeaderDescription { get; set; } } public class Field