[backend/federation] Switch from pancakes:Pronouns (V1) to pancakes:pronouns (V2)
This commit is contained in:
parent
2b25affa2b
commit
df9d3388cf
6 changed files with 17 additions and 32 deletions
|
@ -21,7 +21,7 @@ public static class Constants
|
||||||
public const string MastodonNs = "http://joinmastodon.org/ns";
|
public const string MastodonNs = "http://joinmastodon.org/ns";
|
||||||
public const string MisskeyNs = "https://misskey-hub.net/ns";
|
public const string MisskeyNs = "https://misskey-hub.net/ns";
|
||||||
public const string FedibirdNs = "http://fedibird.com/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 static readonly string[] SystemUsers = ["instance.actor", "relay.actor"];
|
||||||
|
|
||||||
public const string APMime = "application/activity+json";
|
public const string APMime = "application/activity+json";
|
||||||
|
|
|
@ -80,20 +80,15 @@ public class UserRenderer(
|
||||||
|
|
||||||
var attachments = profile?.Fields
|
var attachments = profile?.Fields
|
||||||
.Select(p => new ASField { Name = p.Name, Value = RenderFieldValue(p.Value) })
|
.Select(p => new ASField { Name = p.Name, Value = RenderFieldValue(p.Value) })
|
||||||
.Concat<ASAttachment>(profile.Pronouns != null && profile.Pronouns.Count != 0
|
.Cast<ASAttachment>()
|
||||||
?
|
|
||||||
[
|
|
||||||
profile.Pronouns.TryGetValue("", out var pronouns)
|
|
||||||
? new ASPronouns { Name = new LDLocalizedString(null, pronouns) }
|
|
||||||
: new ASPronouns { Name = new LDLocalizedString { Values = profile.Pronouns! } }
|
|
||||||
]
|
|
||||||
: [])
|
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var summary = profile?.Description != null
|
var summary = profile?.Description != null
|
||||||
? (await mfmConverter.ToHtmlAsync(profile.Description, profile.Mentions, user.Host)).Html
|
? (await mfmConverter.ToHtmlAsync(profile.Description, profile.Mentions, user.Host)).Html
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
var pronouns = profile?.Pronouns != null ? new LDLocalizedString { Values = profile.Pronouns! } : null;
|
||||||
|
|
||||||
return new ASActor
|
return new ASActor
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
|
@ -141,7 +136,8 @@ public class UserRenderer(
|
||||||
PublicKey = keypair.PublicKey
|
PublicKey = keypair.PublicKey
|
||||||
},
|
},
|
||||||
Tags = tags,
|
Tags = tags,
|
||||||
Attachments = attachments
|
Attachments = attachments,
|
||||||
|
Pronouns = pronouns
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,11 @@
|
||||||
"Bite": "https://ns.mia.jetzt/as#Bite",
|
"Bite": "https://ns.mia.jetzt/as#Bite",
|
||||||
"quoteUri": "http://fedibird.com/ns#quoteUri",
|
"quoteUri": "http://fedibird.com/ns#quoteUri",
|
||||||
"EmojiReact": "http://litepub.social/ns#EmojiReact",
|
"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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -131,6 +131,10 @@ public class ASActor : ASObjectWithId
|
||||||
[JC(typeof(VC))]
|
[JC(typeof(VC))]
|
||||||
private XsdString? WebfingerAddressXsd { get; set; }
|
private XsdString? WebfingerAddressXsd { get; set; }
|
||||||
|
|
||||||
|
[J($"{Constants.PancakesNs}#pronouns")]
|
||||||
|
[JC(typeof(LocalizedValueObjectConverter))]
|
||||||
|
public LDLocalizedString? Pronouns { get; set; }
|
||||||
|
|
||||||
[JI]
|
[JI]
|
||||||
public string? WebfingerAddress
|
public string? WebfingerAddress
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,16 +53,6 @@ public class ASField : ASAttachment
|
||||||
public ASField() => Type = $"{Constants.SchemaNs}#PropertyValue";
|
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<ASImage>;
|
public class ASImageConverter : ASSerializer.ListSingleObjectConverter<ASImage>;
|
||||||
|
|
||||||
public sealed class ASAttachmentConverter : JsonConverter
|
public sealed class ASAttachmentConverter : JsonConverter
|
||||||
|
@ -112,7 +102,6 @@ public sealed class ASAttachmentConverter : JsonConverter
|
||||||
$"{Constants.ActivityStreamsNs}#Document" => obj.ToObject<ASDocument?>(),
|
$"{Constants.ActivityStreamsNs}#Document" => obj.ToObject<ASDocument?>(),
|
||||||
$"{Constants.ActivityStreamsNs}#Image" => obj.ToObject<ASImage?>(),
|
$"{Constants.ActivityStreamsNs}#Image" => obj.ToObject<ASImage?>(),
|
||||||
$"{Constants.SchemaNs}#PropertyValue" => obj.ToObject<ASField?>(),
|
$"{Constants.SchemaNs}#PropertyValue" => obj.ToObject<ASField?>(),
|
||||||
$"{Constants.PancakesNs}#Pronouns" => obj.ToObject<ASPronouns?>(),
|
|
||||||
_ => attachment
|
_ => attachment
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,11 +159,7 @@ public class UserService(
|
||||||
.AwaitAllAsync()
|
.AwaitAllAsync()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
var pronouns = actor.Attachments?.OfType<ASPronouns>()
|
var pronouns = actor.Pronouns?.Values.ToDictionary(p => p.Key, p => p.Value ?? "");
|
||||||
.FirstOrDefault(p => p.Name?.Values.Count != 0)
|
|
||||||
?.Name?.Values
|
|
||||||
.Where(p => p.Value != null)
|
|
||||||
.ToDictionary(p => p.Key, p => p.Value ?? "");
|
|
||||||
|
|
||||||
var bio = actor.MkSummary?.ReplaceLineEndings("\n").Trim();
|
var bio = actor.MkSummary?.ReplaceLineEndings("\n").Trim();
|
||||||
if (bio == null)
|
if (bio == null)
|
||||||
|
@ -333,11 +329,7 @@ public class UserService(
|
||||||
.AwaitAllAsync()
|
.AwaitAllAsync()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
var pronouns = actor.Attachments?.OfType<ASPronouns>()
|
var pronouns = actor.Pronouns?.Values.ToDictionary(p => p.Key, p => p.Value ?? "");
|
||||||
.FirstOrDefault(p => p.Name?.Values.Count != 0)
|
|
||||||
?.Name?.Values
|
|
||||||
.Where(p => p.Value != null)
|
|
||||||
.ToDictionary(p => p.Key, p => p.Value ?? "");
|
|
||||||
|
|
||||||
user.Emojis = emoji.Select(p => p.Id).ToList();
|
user.Emojis = emoji.Select(p => p.Id).ToList();
|
||||||
//TODO: FollowersCount
|
//TODO: FollowersCount
|
||||||
|
|
Loading…
Add table
Reference in a new issue