diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs index 3a682791..d7e4a661 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs @@ -51,6 +51,25 @@ public class UserRenderer( var avatarAlt = data?.AvatarAlt.GetValueOrDefault(user.Id); var bannerAlt = data?.BannerAlt.GetValueOrDefault(user.Id); + string? favicon; + string? softwareName; + string? softwareVersion; + if (user.IsRemoteUser) + { + var instInfo = await db.Instances + .Where(p => p.Host == user.Host) + .FirstOrDefaultAsync(); + favicon = instInfo?.FaviconUrl; + softwareName = instInfo?.SoftwareName; + softwareVersion = instInfo?.SoftwareVersion; + } + else + { + favicon = "http://localhost:3000/_content/Iceshrimp.Assets.Branding/favicon.wy3b9djz5j.png"; + softwareName = "iceshrimp"; + softwareVersion = config.Value.Version; + } + var res = new AccountEntity { Id = user.Id, @@ -82,7 +101,24 @@ public class UserRenderer( ? new PleromaUserExtensions { IsAdmin = user.IsAdmin, - IsModerator = user.IsModerator + IsModerator = user.IsModerator, + Favicon = favicon! + } : null, + Akkoma = flags?.IsPleroma.Value == true + ? new AkkomaUserExtensions + { + Instance = new AkkomaInstanceEntity + { + Name = user.Host ?? config.Value.AccountDomain, + NodeInfo = new AkkomaNodeInfoEntity + { + Software = new AkkomaNodeInfoSoftwareEntity + { + Name = softwareName, + Version = softwareVersion + } + } + } } : null }; diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/AccountEntity.cs b/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/AccountEntity.cs index 96716808..84daa6f6 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/AccountEntity.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Schemas/Entities/AccountEntity.cs @@ -31,6 +31,7 @@ public class AccountEntity : IIdentifiable [J("id")] public required string Id { get; set; } [J("last_status_at")] public string? LastStatusAt { get; set; } [J("pleroma")] public required PleromaUserExtensions? Pleroma { get; set; } + [J("akkoma")] public required AkkomaUserExtensions? Akkoma { get; set; } [J("avatar_description")] public required string AvatarDescription { get; set; } [J("header_description")] public required string HeaderDescription { get; set; } diff --git a/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/AkkomaInstanceEntity.cs b/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/AkkomaInstanceEntity.cs new file mode 100644 index 00000000..97b6d254 --- /dev/null +++ b/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/AkkomaInstanceEntity.cs @@ -0,0 +1,9 @@ +using J = System.Text.Json.Serialization.JsonPropertyNameAttribute; + +namespace Iceshrimp.Backend.Controllers.Pleroma.Schemas.Entities; + +public class AkkomaInstanceEntity +{ + [J("name")] public required string Name { get; set; } + [J("nodeinfo")] public required AkkomaNodeInfoEntity NodeInfo { get; set; } +} \ No newline at end of file diff --git a/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/AkkomaNodeInfoEntity.cs b/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/AkkomaNodeInfoEntity.cs new file mode 100644 index 00000000..d712dab5 --- /dev/null +++ b/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/AkkomaNodeInfoEntity.cs @@ -0,0 +1,8 @@ +using J = System.Text.Json.Serialization.JsonPropertyNameAttribute; + +namespace Iceshrimp.Backend.Controllers.Pleroma.Schemas.Entities; + +public class AkkomaNodeInfoEntity +{ + [J("software")] public required AkkomaNodeInfoSoftwareEntity Software { get; set; } +} \ No newline at end of file diff --git a/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/AkkomaNodeInfoSoftwareEntity.cs b/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/AkkomaNodeInfoSoftwareEntity.cs new file mode 100644 index 00000000..ccccbe5d --- /dev/null +++ b/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/AkkomaNodeInfoSoftwareEntity.cs @@ -0,0 +1,9 @@ +using J = System.Text.Json.Serialization.JsonPropertyNameAttribute; + +namespace Iceshrimp.Backend.Controllers.Pleroma.Schemas.Entities; + +public class AkkomaNodeInfoSoftwareEntity +{ + [J("name")] public required string? Name { get; set; } + [J("version")] public required string? Version { get; set; } +} \ No newline at end of file diff --git a/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/AkkomaUserExtensions.cs b/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/AkkomaUserExtensions.cs new file mode 100644 index 00000000..d2cd6891 --- /dev/null +++ b/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/AkkomaUserExtensions.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using J = System.Text.Json.Serialization.JsonPropertyNameAttribute; + +namespace Iceshrimp.Backend.Controllers.Pleroma.Schemas.Entities; + +[Keyless] +public class AkkomaUserExtensions +{ + [J("instance")] public required AkkomaInstanceEntity Instance { get; set; } +} \ No newline at end of file diff --git a/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/PleromaUserExtensions.cs b/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/PleromaUserExtensions.cs index c15d1596..5f0b7807 100644 --- a/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/PleromaUserExtensions.cs +++ b/Iceshrimp.Backend/Controllers/Pleroma/Schemas/Entities/PleromaUserExtensions.cs @@ -8,4 +8,5 @@ public class PleromaUserExtensions { [J("is_admin")] public required bool IsAdmin { get; set; } [J("is_moderator")] public required bool IsModerator { get; set; } + [J("favicon")] public required string Favicon { get; set; } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Properties/launchSettings.json b/Iceshrimp.Backend/Properties/launchSettings.json index 8406b1ed..4a336233 100644 --- a/Iceshrimp.Backend/Properties/launchSettings.json +++ b/Iceshrimp.Backend/Properties/launchSettings.json @@ -6,6 +6,7 @@ "dotnetRunMessages": true, "launchBrowser": false, "externalUrlConfiguration": true, + "commandLineArgs": "--migrate-and-start", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/Iceshrimp.Backend/configuration.ini b/Iceshrimp.Backend/configuration.ini index b72a8e8e..21dea1a4 100644 --- a/Iceshrimp.Backend/configuration.ini +++ b/Iceshrimp.Backend/configuration.ini @@ -184,7 +184,7 @@ ProxyRemoteMedia = true [Storage:Local] ;; Path where media is stored at. Must be writable for the service user. -Path = /path/to/media/location +Path = /home/luke/Documents/shrimp [Storage:ObjectStorage] ;;Endpoint = endpoint.example.org