add limits to switch members and proxy tag length
This commit is contained in:
@@ -78,6 +78,8 @@ namespace PluralKit.Bot
|
||||
if (tagToAdd.IsEmpty) throw Errors.EmptyProxyTags(target);
|
||||
if (target.ProxyTags.Contains(tagToAdd))
|
||||
throw Errors.ProxyTagAlreadyExists(tagToAdd, target);
|
||||
if (tagToAdd.ProxyString.Length > Limits.MaxProxyTagLength)
|
||||
throw new PKError($"Proxy tag too long ({tagToAdd.ProxyString.Length} > {Limits.MaxProxyTagLength} characters).");
|
||||
|
||||
if (!await WarnOnConflict(tagToAdd))
|
||||
throw Errors.GenericCancelled();
|
||||
|
@@ -40,6 +40,8 @@ namespace PluralKit.Bot
|
||||
// Make sure there are no dupes in the list
|
||||
// We do this by checking if removing duplicate member IDs results in a list of different length
|
||||
if (members.Select(m => m.Id).Distinct().Count() != members.Count) throw Errors.DuplicateSwitchMembers;
|
||||
if (members.Count > Limits.MaxSwitchMemberCount)
|
||||
throw new PKError($"Switch contains too many members ({members.Count} > {Limits.MaxSwitchMemberCount} members).");
|
||||
|
||||
// Find the last switch and its members if applicable
|
||||
await using var conn = await _db.Obtain();
|
||||
|
Reference in New Issue
Block a user