[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() .AwaitAllAsync()
: null; : null;
var fieldsSource = source
? profile?.Fields.Select(p => new Field { Name = p.Name, Value = p.Value }).ToList() ?? []
: [];
var res = new AccountEntity var res = new AccountEntity
{ {
Id = user.Id, Id = user.Id,
@ -66,7 +70,7 @@ public class UserRenderer(IOptions<Config.InstanceSection> config, MfmConverter
//TODO: populate these //TODO: populate these
res.Source = new AccountSource res.Source = new AccountSource
{ {
Fields = [], Fields = fieldsSource,
Language = "", Language = "",
Note = profile?.Description ?? "", Note = profile?.Description ?? "",
Privacy = StatusEntity.EncodeVisibility(user.UserSettings?.DefaultNoteVisibility ?? Privacy = StatusEntity.EncodeVisibility(user.UserSettings?.DefaultNoteVisibility ??

View file

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