[backend/federation] Use LDLocalizedString for pancakes:Pronouns
This commit is contained in:
parent
9e713419ce
commit
2b25affa2b
3 changed files with 15 additions and 26 deletions
|
@ -84,8 +84,8 @@ public class UserRenderer(
|
|||
?
|
||||
[
|
||||
profile.Pronouns.TryGetValue("", out var pronouns)
|
||||
? new ASPronouns { Name = pronouns }
|
||||
: new ASPronouns { NameMap = profile.Pronouns }
|
||||
? new ASPronouns { Name = new LDLocalizedString(null, pronouns) }
|
||||
: new ASPronouns { Name = new LDLocalizedString { Values = profile.Pronouns! } }
|
||||
]
|
||||
: [])
|
||||
.ToList();
|
||||
|
|
|
@ -58,14 +58,9 @@ public class ASPronouns : ASAttachment
|
|||
public ASPronouns() => Type = $"{Constants.PancakesNs}#Pronouns";
|
||||
|
||||
[J($"{Constants.ActivityStreamsNs}#name")]
|
||||
[JC(typeof(ValueObjectConverter))]
|
||||
[JC(typeof(LocalizedValueObjectConverter))]
|
||||
[JI(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[J($"{Constants.ActivityStreamsNs}#nameMap")]
|
||||
[JC(typeof(ValueObjectConverter))]
|
||||
[JI(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public Dictionary<string, string>? NameMap { get; set; }
|
||||
public LDLocalizedString? Name { get; set; }
|
||||
}
|
||||
|
||||
public class ASImageConverter : ASSerializer.ListSingleObjectConverter<ASImage>;
|
||||
|
|
|
@ -159,14 +159,11 @@ public class UserService(
|
|||
.AwaitAllAsync()
|
||||
: null;
|
||||
|
||||
var pronounsAttachment = actor.Attachments?.OfType<ASPronouns>()
|
||||
.FirstOrDefault(p => p is { Name: not null } or { NameMap: not null });
|
||||
var pronouns = pronounsAttachment switch
|
||||
{
|
||||
{ Name: not null } => new Dictionary<string, string> { { "", pronounsAttachment.Name } },
|
||||
{ NameMap: not null } => pronounsAttachment.NameMap,
|
||||
_ => null
|
||||
};
|
||||
var pronouns = actor.Attachments?.OfType<ASPronouns>()
|
||||
.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();
|
||||
if (bio == null)
|
||||
|
@ -336,14 +333,11 @@ public class UserService(
|
|||
.AwaitAllAsync()
|
||||
: null;
|
||||
|
||||
var pronounsAttachment = actor.Attachments?.OfType<ASPronouns>()
|
||||
.FirstOrDefault(p => p is { Name: not null } or { NameMap: not null });
|
||||
var pronouns = pronounsAttachment switch
|
||||
{
|
||||
{ Name: not null } => new Dictionary<string, string> { { "", pronounsAttachment.Name } },
|
||||
{ NameMap: not null } => pronounsAttachment.NameMap,
|
||||
_ => null
|
||||
};
|
||||
var pronouns = actor.Attachments?.OfType<ASPronouns>()
|
||||
.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();
|
||||
//TODO: FollowersCount
|
||||
|
|
Loading…
Add table
Reference in a new issue