feat: add avatar/bio/links/names/pronouns to user page

This commit is contained in:
sam 2024-09-24 20:56:10 +02:00
parent 412d720abc
commit 862a64840e
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
16 changed files with 650 additions and 90 deletions

View file

@ -62,9 +62,28 @@ public class UsersController(
if (req.HasProperty(nameof(req.Links)))
{
// TODO: validate link length
user.Links = req.Links ?? [];
}
if (req.Names != null)
{
errors.AddRange(ValidationUtils.ValidateFieldEntries(req.Names, CurrentUser!.CustomPreferences, "names"));
user.Names = req.Names.ToList();
}
if (req.Pronouns != null)
{
errors.AddRange(ValidationUtils.ValidatePronouns(req.Pronouns, CurrentUser!.CustomPreferences));
user.Pronouns = req.Pronouns.ToList();
}
if (req.Fields != null)
{
errors.AddRange(ValidationUtils.ValidateFields(req.Fields.ToList(), CurrentUser!.CustomPreferences));
user.Fields = req.Fields.ToList();
}
if (req.HasProperty(nameof(req.Avatar)))
errors.Add(("avatar", ValidationUtils.ValidateAvatar(req.Avatar)));
@ -157,6 +176,9 @@ public class UsersController(
public string? Bio { get; init; }
public string? Avatar { get; init; }
public string[]? Links { get; init; }
public FieldEntry[]? Names { get; init; }
public Pronoun[]? Pronouns { get; init; }
public Field[]? Fields { get; init; }
}