feat: initial 6-character HID rework

This commit is contained in:
Iris System 2024-04-28 15:46:06 +12:00
parent 73f43b8cb3
commit 9f56697241
30 changed files with 208 additions and 91 deletions

View file

@ -29,9 +29,9 @@ public class Admin
if (target == null)
throw new PKError("Unknown system.");
var newHid = ctx.PopArgument();
if (!Regex.IsMatch(newHid, "^[a-z]{5}$"))
throw new PKError($"Invalid new system ID `{newHid}`.");
var input = ctx.PopArgument();
if (!input.TryParseHid(out var newHid))
throw new PKError($"Invalid new system ID `{input}`.");
var existingSystem = await ctx.Repository.GetSystemByHid(newHid);
if (existingSystem != null)
@ -52,9 +52,9 @@ public class Admin
if (target == null)
throw new PKError("Unknown member.");
var newHid = ctx.PopArgument();
if (!Regex.IsMatch(newHid, "^[a-z]{5}$"))
throw new PKError($"Invalid new member ID `{newHid}`.");
var input = ctx.PopArgument();
if (!input.TryParseHid(out var newHid))
throw new PKError($"Invalid new member ID `{input}`.");
var existingMember = await ctx.Repository.GetMemberByHid(newHid);
if (existingMember != null)
@ -78,9 +78,9 @@ public class Admin
if (target == null)
throw new PKError("Unknown group.");
var newHid = ctx.PopArgument();
if (!Regex.IsMatch(newHid, "^[a-z]{5}$"))
throw new PKError($"Invalid new group ID `{newHid}`.");
var input = ctx.PopArgument();
if (!input.TryParseHid(out var newHid))
throw new PKError($"Invalid new group ID `{input}`.");
var existingGroup = await ctx.Repository.GetGroupByHid(newHid);
if (existingGroup != null)