diff --git a/Iceshrimp.Backend/Core/Configuration/Constants.cs b/Iceshrimp.Backend/Core/Configuration/Constants.cs index 496405fc..2acc10b8 100644 --- a/Iceshrimp.Backend/Core/Configuration/Constants.cs +++ b/Iceshrimp.Backend/Core/Configuration/Constants.cs @@ -21,7 +21,7 @@ public static class Constants public const string MastodonNs = "http://joinmastodon.org/ns"; public const string MisskeyNs = "https://misskey-hub.net/ns"; public const string FedibirdNs = "http://fedibird.com/ns"; - public const string PancakesNs = "https://ns.pancakes.gay/as/"; + public const string PancakesNs = "https://ns.pancakes.gay/as"; public static readonly string[] SystemUsers = ["instance.actor", "relay.actor"]; public const string APMime = "application/activity+json"; diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/UserRenderer.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/UserRenderer.cs index 1ecdfccd..2d75b8e1 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityPub/UserRenderer.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/UserRenderer.cs @@ -80,20 +80,15 @@ public class UserRenderer( var attachments = profile?.Fields .Select(p => new ASField { Name = p.Name, Value = RenderFieldValue(p.Value) }) - .Concat(profile.Pronouns != null && profile.Pronouns.Count != 0 - ? - [ - profile.Pronouns.TryGetValue("", out var pronouns) - ? new ASPronouns { Name = new LDLocalizedString(null, pronouns) } - : new ASPronouns { Name = new LDLocalizedString { Values = profile.Pronouns! } } - ] - : []) + .Cast() .ToList(); var summary = profile?.Description != null ? (await mfmConverter.ToHtmlAsync(profile.Description, profile.Mentions, user.Host)).Html : null; + var pronouns = profile?.Pronouns != null ? new LDLocalizedString { Values = profile.Pronouns! } : null; + return new ASActor { Id = id, @@ -141,7 +136,8 @@ public class UserRenderer( PublicKey = keypair.PublicKey }, Tags = tags, - Attachments = attachments + Attachments = attachments, + Pronouns = pronouns }; } diff --git a/Iceshrimp.Backend/Core/Federation/ActivityStreams/Contexts/iceshrimp.json b/Iceshrimp.Backend/Core/Federation/ActivityStreams/Contexts/iceshrimp.json index 71daf9ae..d8de0715 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityStreams/Contexts/iceshrimp.json +++ b/Iceshrimp.Backend/Core/Federation/ActivityStreams/Contexts/iceshrimp.json @@ -44,7 +44,11 @@ "Bite": "https://ns.mia.jetzt/as#Bite", "quoteUri": "http://fedibird.com/ns#quoteUri", "EmojiReact": "http://litepub.social/ns#EmojiReact", - "Pronouns": "https://ns.pancakes.gay/as/#Pronouns" + "pancakes": "https://ns.pancakes.gay/as#", + "pancakes:pronouns": { + "@id": "https://ns.pancakes.gay/as#pronouns", + "@container": "@language" + } } ] } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASActor.cs b/Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASActor.cs index 44072b7a..7fbea6d3 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASActor.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASActor.cs @@ -131,6 +131,10 @@ public class ASActor : ASObjectWithId [JC(typeof(VC))] private XsdString? WebfingerAddressXsd { get; set; } + [J($"{Constants.PancakesNs}#pronouns")] + [JC(typeof(LocalizedValueObjectConverter))] + public LDLocalizedString? Pronouns { get; set; } + [JI] public string? WebfingerAddress { diff --git a/Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASAttachment.cs b/Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASAttachment.cs index 5bc77ddc..7e2c3fb0 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASAttachment.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASAttachment.cs @@ -53,16 +53,6 @@ public class ASField : ASAttachment public ASField() => Type = $"{Constants.SchemaNs}#PropertyValue"; } -public class ASPronouns : ASAttachment -{ - public ASPronouns() => Type = $"{Constants.PancakesNs}#Pronouns"; - - [J($"{Constants.ActivityStreamsNs}#name")] - [JC(typeof(LocalizedValueObjectConverter))] - [JI(Condition = JsonIgnoreCondition.WhenWritingNull)] - public LDLocalizedString? Name { get; set; } -} - public class ASImageConverter : ASSerializer.ListSingleObjectConverter; public sealed class ASAttachmentConverter : JsonConverter @@ -112,7 +102,6 @@ public sealed class ASAttachmentConverter : JsonConverter $"{Constants.ActivityStreamsNs}#Document" => obj.ToObject(), $"{Constants.ActivityStreamsNs}#Image" => obj.ToObject(), $"{Constants.SchemaNs}#PropertyValue" => obj.ToObject(), - $"{Constants.PancakesNs}#Pronouns" => obj.ToObject(), _ => attachment }; } diff --git a/Iceshrimp.Backend/Core/Services/UserService.cs b/Iceshrimp.Backend/Core/Services/UserService.cs index 2af86de0..48255a82 100644 --- a/Iceshrimp.Backend/Core/Services/UserService.cs +++ b/Iceshrimp.Backend/Core/Services/UserService.cs @@ -159,11 +159,7 @@ public class UserService( .AwaitAllAsync() : null; - var pronouns = actor.Attachments?.OfType() - .FirstOrDefault(p => p.Name?.Values.Count != 0) - ?.Name?.Values - .Where(p => p.Value != null) - .ToDictionary(p => p.Key, p => p.Value ?? ""); + var pronouns = actor.Pronouns?.Values.ToDictionary(p => p.Key, p => p.Value ?? ""); var bio = actor.MkSummary?.ReplaceLineEndings("\n").Trim(); if (bio == null) @@ -333,11 +329,7 @@ public class UserService( .AwaitAllAsync() : null; - var pronouns = actor.Attachments?.OfType() - .FirstOrDefault(p => p.Name?.Values.Count != 0) - ?.Name?.Values - .Where(p => p.Value != null) - .ToDictionary(p => p.Key, p => p.Value ?? ""); + var pronouns = actor.Pronouns?.Values.ToDictionary(p => p.Key, p => p.Value ?? ""); user.Emojis = emoji.Select(p => p.Id).ToList(); //TODO: FollowersCount