feat(api): throw error when patching autoproxy member with autoproxy mode set to latch
This commit is contained in:
parent
59f0a5ec3e
commit
7bf6c2064f
@ -68,6 +68,7 @@ public class DiscordControllerV2: PKControllerBase
|
|||||||
|
|
||||||
// this is less than great, but at least it's legible
|
// this is less than great, but at least it's legible
|
||||||
if (patch.AutoproxyMember.Value == null)
|
if (patch.AutoproxyMember.Value == null)
|
||||||
|
{
|
||||||
if (patch.AutoproxyMode.IsPresent)
|
if (patch.AutoproxyMode.IsPresent)
|
||||||
{
|
{
|
||||||
if (patch.AutoproxyMode.Value == AutoproxyMode.Member)
|
if (patch.AutoproxyMode.Value == AutoproxyMode.Member)
|
||||||
@ -77,6 +78,19 @@ public class DiscordControllerV2: PKControllerBase
|
|||||||
{
|
{
|
||||||
throw Errors.MissingAutoproxyMember;
|
throw Errors.MissingAutoproxyMember;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (patch.AutoproxyMode.IsPresent)
|
||||||
|
{
|
||||||
|
if (patch.AutoproxyMode.Value == AutoproxyMode.Latch)
|
||||||
|
throw Errors.PatchLatchMemberError;
|
||||||
|
}
|
||||||
|
else if (settings.AutoproxyMode == AutoproxyMode.Latch)
|
||||||
|
{
|
||||||
|
throw Errors.PatchLatchMemberError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var newSettings = await _repo.UpdateSystemGuild(system.Id, guild_id, patch);
|
var newSettings = await _repo.UpdateSystemGuild(system.Id, guild_id, patch);
|
||||||
|
|
||||||
|
@ -111,6 +111,7 @@ public static class Errors
|
|||||||
public static PKError InvalidSwitchId = new(400, 40006, "Invalid switch ID.");
|
public static PKError InvalidSwitchId = new(400, 40006, "Invalid switch ID.");
|
||||||
public static PKError MemberLimitReached = new(400, 40007, "Member limit reached.");
|
public static PKError MemberLimitReached = new(400, 40007, "Member limit reached.");
|
||||||
public static PKError GroupLimitReached = new(400, 40008, "Group limit reached.");
|
public static PKError GroupLimitReached = new(400, 40008, "Group limit reached.");
|
||||||
|
public static PKError PatchLatchMemberError = new(400, 40009, "Cannot patch autoproxy member with latch-mode autoproxy.");
|
||||||
public static PKError Unimplemented = new(501, 50001, "Unimplemented");
|
public static PKError Unimplemented = new(501, 50001, "Unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user