[backend/api] Render remote language-mapped pronouns

This commit is contained in:
pancakes 2025-01-26 18:03:25 +10:00 committed by Laura Hausmann
parent a27280885c
commit 3bfb133661
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -57,6 +57,16 @@ public class UserProfileRenderer(DatabaseContext db, IOptions<Config.InstanceSec
var url = user.Host != null ? user.UserProfile?.Url ?? user.Uri : user.GetPublicUrl(instance.Value); var url = user.Host != null ? user.UserProfile?.Url ?? user.Uri : user.GetPublicUrl(instance.Value);
// 1. Try to get language mapped (NameMap) pronouns that match the local user's language
// 2. Try to get language mapped (NameMap) pronouns that match the requested user's profile language
// 3. Try to get the generic language (Name) pronouns
string? pronouns = null;
if (!string.IsNullOrWhiteSpace(localUser?.UserProfile?.Lang))
pronouns = user.UserProfile?.Pronouns?.GetValueOrDefault(localUser.UserProfile.Lang);
if (!string.IsNullOrWhiteSpace(user.UserProfile?.Lang))
pronouns ??= user.UserProfile.Pronouns?.GetValueOrDefault(user.UserProfile.Lang);
pronouns ??= user.UserProfile?.Pronouns?.GetValueOrDefault("");
return new UserProfileResponse return new UserProfileResponse
{ {
Id = user.Id, Id = user.Id,
@ -70,7 +80,7 @@ public class UserProfileRenderer(DatabaseContext db, IOptions<Config.InstanceSec
Role = role, Role = role,
IsLocked = user.IsLocked, IsLocked = user.IsLocked,
Url = url, Url = url,
Pronouns = user.UserProfile?.Pronouns?.GetValueOrDefault("") Pronouns = pronouns
}; };
} }