[backend/masto-client] Return profile fields in /accounts/verify_credentials

This commit is contained in:
Laura Hausmann 2024-04-28 02:03:13 +02:00
parent 0414c791e6
commit ec6a3f5e73
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 11 additions and 7 deletions

View file

@ -36,6 +36,10 @@ public class UserRenderer(IOptions<Config.InstanceSection> config, MfmConverter
.AwaitAllAsync()
: null;
var fieldsSource = source
? profile?.Fields.Select(p => new Field { Name = p.Name, Value = p.Value }).ToList() ?? []
: [];
var res = new AccountEntity
{
Id = user.Id,
@ -66,7 +70,7 @@ public class UserRenderer(IOptions<Config.InstanceSection> config, MfmConverter
//TODO: populate these
res.Source = new AccountSource
{
Fields = [],
Fields = fieldsSource,
Language = "",
Note = profile?.Description ?? "",
Privacy = StatusEntity.EncodeVisibility(user.UserSettings?.DefaultNoteVisibility ??
@ -105,7 +109,7 @@ public class UserRenderer(IOptions<Config.InstanceSection> config, MfmConverter
{
var userList = users.ToList();
if (userList.Count == 0) return [];
var emoji = await GetEmoji(userList);
var emoji = await GetEmoji(userList);
return await userList.Select(p => RenderAsync(p, emoji)).AwaitAllAsync();
}
}

View file

@ -38,9 +38,9 @@ public class Field
public class AccountSource
{
[J("language")] public required string Language { get; set; }
[J("note")] public required string Note { get; set; }
[J("privacy")] public required string Privacy { get; set; }
[J("sensitive")] public required bool Sensitive { get; set; }
[J("fields")] public required Field[] Fields { get; set; }
[J("language")] public required string Language { get; set; }
[J("note")] public required string Note { get; set; }
[J("privacy")] public required string Privacy { get; set; }
[J("sensitive")] public required bool Sensitive { get; set; }
[J("fields")] public required List<Field> Fields { get; set; }
}