Add display name editing

- Set display name during member POST
- Update display name during member PATCH
This commit is contained in:
Grey Himmel 2019-08-09 11:37:52 -04:00 committed by GitHub
parent 1cfeaf281b
commit d38c38cb9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,6 +41,8 @@ namespace PluralKit.API.Controllers
// Explicit bounds checks // Explicit bounds checks
if (newMember.Name != null && newMember.Name.Length > Limits.MaxMemberNameLength) if (newMember.Name != null && newMember.Name.Length > Limits.MaxMemberNameLength)
return BadRequest($"Member name too long ({newMember.Name.Length} > {Limits.MaxMemberNameLength}."); return BadRequest($"Member name too long ({newMember.Name.Length} > {Limits.MaxMemberNameLength}.");
if (newMember.DisplayName != null && newMember.DisplayName.Length > Limits.MaxMemberNameLength)
return BadRequest($"Member display name too long ({newMember.DisplayName.Length} > {Limits.MaxMemberNameLength}.");
if (newMember.Pronouns != null && newMember.Pronouns.Length > Limits.MaxPronounsLength) if (newMember.Pronouns != null && newMember.Pronouns.Length > Limits.MaxPronounsLength)
return BadRequest($"Member pronouns too long ({newMember.Pronouns.Length} > {Limits.MaxPronounsLength}."); return BadRequest($"Member pronouns too long ({newMember.Pronouns.Length} > {Limits.MaxPronounsLength}.");
if (newMember.Description != null && newMember.Description.Length > Limits.MaxDescriptionLength) if (newMember.Description != null && newMember.Description.Length > Limits.MaxDescriptionLength)
@ -57,6 +59,7 @@ namespace PluralKit.API.Controllers
var member = await _members.Create(system, newMember.Name); var member = await _members.Create(system, newMember.Name);
member.Name = newMember.Name; member.Name = newMember.Name;
member.DisplayName = newMember.DisplayName;
member.Color = newMember.Color; member.Color = newMember.Color;
member.AvatarUrl = newMember.AvatarUrl; member.AvatarUrl = newMember.AvatarUrl;
member.Birthday = newMember.Birthday; member.Birthday = newMember.Birthday;
@ -84,6 +87,8 @@ namespace PluralKit.API.Controllers
// Explicit bounds checks // Explicit bounds checks
if (newMember.Name != null && newMember.Name.Length > Limits.MaxMemberNameLength) if (newMember.Name != null && newMember.Name.Length > Limits.MaxMemberNameLength)
return BadRequest($"Member name too long ({newMember.Name.Length} > {Limits.MaxMemberNameLength}."); return BadRequest($"Member name too long ({newMember.Name.Length} > {Limits.MaxMemberNameLength}.");
if (newMember.DisplayName != null && newMember.DisplayName.Length > Limits.MaxMemberNameLength)
return BadRequest($"Member display name too long ({newMember.DisplayName.Length} > {Limits.MaxMemberNameLength}.");
if (newMember.Pronouns != null && newMember.Pronouns.Length > Limits.MaxPronounsLength) if (newMember.Pronouns != null && newMember.Pronouns.Length > Limits.MaxPronounsLength)
return BadRequest($"Member pronouns too long ({newMember.Pronouns.Length} > {Limits.MaxPronounsLength}."); return BadRequest($"Member pronouns too long ({newMember.Pronouns.Length} > {Limits.MaxPronounsLength}.");
if (newMember.Description != null && newMember.Description.Length > Limits.MaxDescriptionLength) if (newMember.Description != null && newMember.Description.Length > Limits.MaxDescriptionLength)
@ -98,6 +103,7 @@ namespace PluralKit.API.Controllers
return BadRequest(); return BadRequest();
member.Name = newMember.Name; member.Name = newMember.Name;
member.DisplayName = newMember.DisplayName;
member.Color = newMember.Color; member.Color = newMember.Color;
member.AvatarUrl = newMember.AvatarUrl; member.AvatarUrl = newMember.AvatarUrl;
member.Birthday = newMember.Birthday; member.Birthday = newMember.Birthday;