diff --git a/Iceshrimp.Backend/Controllers/Mastodon/InstanceController.cs b/Iceshrimp.Backend/Controllers/Mastodon/InstanceController.cs index 05e8105f..2e993d20 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/InstanceController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/InstanceController.cs @@ -61,14 +61,20 @@ public class InstanceController( && !Constants.SystemUsers.Contains(p.UsernameLower) && p.LastActiveDate > cutoff); - var (instanceName, instanceDescription, adminContact) = + var (instanceName, instanceDescription, adminContact, iconId) = await meta.GetManyAsync(MetaEntity.InstanceName, MetaEntity.InstanceDescription, - MetaEntity.AdminContactEmail); + MetaEntity.AdminContactEmail, MetaEntity.IconFileId); + + var favicon = await db.DriveFiles.Where(p => p.Id == iconId) + .Select(p => new InstanceIcon(p.PublicUrl ?? p.RawAccessUrl, p.Properties.Width ?? 128, + p.Properties.Height ?? 128)) + .FirstOrDefaultAsync(); return new InstanceInfoV2Response(config.Value, instanceName, instanceDescription, adminContact) { Usage = new InstanceUsage { Users = new InstanceUsersUsage { ActiveMonth = activeMonth } }, - Rules = await GetRules() + Rules = await GetRules(), + Icons = favicon != null ? [favicon] : [] }; } diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Schemas/InstanceInfoV2Response.cs b/Iceshrimp.Backend/Controllers/Mastodon/Schemas/InstanceInfoV2Response.cs index 0b05e1fb..38095a45 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Schemas/InstanceInfoV2Response.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Schemas/InstanceInfoV2Response.cs @@ -29,6 +29,8 @@ public class InstanceInfoV2Response( [J("rules")] public required List Rules { get; set; } + [J("icon")] public required List Icons { get; set; } + //TODO: add the rest } @@ -76,4 +78,10 @@ public class InstanceExtendedDescription(string? description) [J("content")] public string Content => description ?? "This Iceshrimp.NET instance does not appear to have a description"; +} + +public class InstanceIcon(string src, int width, int height) +{ + [J("src")] public string Url => src; + [J("size")] public string Size => $"{width}x{height}"; } \ No newline at end of file