feat(backend): validate links, allow setting links in POST /users/@me/members
This commit is contained in:
parent
a3cbdc1a08
commit
8fe8755183
5 changed files with 37 additions and 5 deletions
|
@ -54,7 +54,8 @@ public class MembersController(
|
|||
("avatar", ValidationUtils.ValidateAvatar(req.Avatar)),
|
||||
.. ValidationUtils.ValidateFields(req.Fields, CurrentUser!.CustomPreferences),
|
||||
.. ValidationUtils.ValidateFieldEntries(req.Names?.ToArray(), CurrentUser!.CustomPreferences, "names"),
|
||||
.. ValidationUtils.ValidatePronouns(req.Pronouns?.ToArray(), CurrentUser!.CustomPreferences)
|
||||
.. ValidationUtils.ValidatePronouns(req.Pronouns?.ToArray(), CurrentUser!.CustomPreferences),
|
||||
.. ValidationUtils.ValidateLinks(req.Links)
|
||||
]);
|
||||
|
||||
var member = new Member
|
||||
|
@ -64,6 +65,7 @@ public class MembersController(
|
|||
Name = req.Name,
|
||||
DisplayName = req.DisplayName,
|
||||
Bio = req.Bio,
|
||||
Links = req.Links ?? [],
|
||||
Fields = req.Fields ?? [],
|
||||
Names = req.Names ?? [],
|
||||
Pronouns = req.Pronouns ?? [],
|
||||
|
@ -113,6 +115,7 @@ public class MembersController(
|
|||
string? Bio,
|
||||
string? Avatar,
|
||||
bool? Unlisted,
|
||||
string[]? Links,
|
||||
List<FieldEntry>? Names,
|
||||
List<Pronoun>? Pronouns,
|
||||
List<Field>? Fields);
|
||||
|
|
|
@ -64,7 +64,7 @@ public class UsersController(
|
|||
|
||||
if (req.HasProperty(nameof(req.Links)))
|
||||
{
|
||||
// TODO: validate link length
|
||||
errors.AddRange(ValidationUtils.ValidateLinks(req.Links));
|
||||
user.Links = req.Links ?? [];
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ public class UsersController(
|
|||
.SetProperty(u => u.Sid, _ => db.FindFreeUserSid())
|
||||
.SetProperty(u => u.LastSidReroll, clock.GetCurrentInstant())
|
||||
.SetProperty(u => u.LastActive, clock.GetCurrentInstant()));
|
||||
|
||||
|
||||
var user = await db.ResolveUserAsync(CurrentUser.Id);
|
||||
return Ok(await userRenderer.RenderUserAsync(user, CurrentUser, CurrentToken, renderMembers: false));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue