fix(api): fix autoproxy mode check when patching member

This commit is contained in:
spiral 2022-12-31 02:22:38 +00:00
parent 5c0472eb95
commit 42905ba3bd
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E

View File

@ -68,7 +68,10 @@ public class AutoproxyControllerV2: PKControllerBase
patch.AssertIsValid();
if (updateMember && member == null)
patch.Errors.Add(new("autoproxy_member", "Member not found."));
if (updateMember && ((patch.AutoproxyMode.IsPresent && patch.AutoproxyMode.Value == AutoproxyMode.Latch) || oldData.AutoproxyMode == AutoproxyMode.Latch))
if (updateMember && !(
(patch.AutoproxyMode.IsPresent && patch.AutoproxyMode.Value == AutoproxyMode.Member)
|| (!patch.AutoproxyMode.IsPresent && oldData.AutoproxyMode == AutoproxyMode.Member))
)
patch.Errors.Add(new("autoproxy_member", "Cannot update autoproxy member if autoproxy mode is set to latch"));
if (patch.Errors.Count > 0)
throw new ModelParseError(patch.Errors);