[backend/api] Render remote language-mapped pronouns
This commit is contained in:
parent
a27280885c
commit
3bfb133661
1 changed files with 11 additions and 1 deletions
|
@ -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
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue