diff --git a/PluralKit.Bot/Commands/MemberCommands.cs b/PluralKit.Bot/Commands/MemberCommands.cs index ab7ca99d..e028c315 100644 --- a/PluralKit.Bot/Commands/MemberCommands.cs +++ b/PluralKit.Bot/Commands/MemberCommands.cs @@ -30,12 +30,6 @@ namespace PluralKit.Bot.Commands // Hard name length cap if (memberName.Length > Limits.MaxMemberNameLength) throw Errors.MemberNameTooLongError(memberName.Length); - // Warn if member name will be unproxyable (with/without tag) - if (memberName.Length > ctx.System.MaxMemberNameLength) { - var msg = await ctx.Reply($"{Emojis.Warn} Member name too long ({memberName.Length} > {ctx.System.MaxMemberNameLength} characters), this member will be unproxyable. Do you want to create it anyway? (You can change the name later, or set a member display name)"); - if (!await ctx.PromptYesNo(msg)) throw new PKError("Member creation cancelled."); - } - // Warn if there's already a member by this name var existingMember = await _data.GetMemberByName(ctx.System, memberName); if (existingMember != null) { @@ -74,12 +68,6 @@ namespace PluralKit.Bot.Commands // Hard name length cap if (newName.Length > Limits.MaxMemberNameLength) throw Errors.MemberNameTooLongError(newName.Length); - // Warn if member name will be unproxyable (with/without tag), only if member doesn't have a display name - if (target.DisplayName == null && newName.Length > ctx.System.MaxMemberNameLength) { - var msg = await ctx.Reply($"{Emojis.Warn} New member name too long ({newName.Length} > {ctx.System.MaxMemberNameLength} characters), this member will be unproxyable. Do you want to change it anyway? (You can set a member display name instead)"); - if (!await ctx.PromptYesNo(msg)) throw new PKError("Member renaming cancelled."); - } - // Warn if there's already a member by this name var existingMember = await _data.GetMemberByName(ctx.System, newName); if (existingMember != null) { @@ -255,10 +243,7 @@ namespace PluralKit.Bot.Commands if (target.System != ctx.System.Id) throw Errors.NotOwnMemberError; var newDisplayName = ctx.RemainderOrNull(); - // Refuse if proxy name will be unproxyable (with/without tag) - if (newDisplayName != null && newDisplayName.Length > ctx.System.MaxMemberNameLength) - throw Errors.DisplayNameTooLong(newDisplayName, ctx.System.MaxMemberNameLength); - + target.DisplayName = newDisplayName; await _data.SaveMember(target); @@ -270,14 +255,7 @@ namespace PluralKit.Bot.Commands } else { - successStr += $"Member display name cleared. "; - - // If we're removing display name and the *real* name will be unproxyable, warn. - if (target.Name.Length > ctx.System.MaxMemberNameLength) - successStr += - $" {Emojis.Warn} This member's actual name is too long ({target.Name.Length} > {ctx.System.MaxMemberNameLength} characters), and thus cannot be proxied."; - else - successStr += $"This member will now be proxied using their member name \"{target.Name.SanitizeMentions()}\"."; + successStr += $"Member display name cleared. This member will now be proxied using their member name \"{target.Name.SanitizeMentions()}\"."; } await ctx.Reply(successStr); diff --git a/PluralKit.Bot/Commands/SystemCommands.cs b/PluralKit.Bot/Commands/SystemCommands.cs index 8a8f31a3..aa0be628 100644 --- a/PluralKit.Bot/Commands/SystemCommands.cs +++ b/PluralKit.Bot/Commands/SystemCommands.cs @@ -72,19 +72,8 @@ namespace PluralKit.Bot.Commands ctx.System.Tag = newTag; if (newTag != null) - { - if (newTag.Length > Limits.MaxSystemTagLength) throw Errors.SystemNameTooLongError(newTag.Length); - - // TODO: The proxy name limit is long enough now that this probably doesn't matter much. - // // Check unproxyable messages *after* changing the tag (so it's seen in the method) but *before* we save to DB (so we can cancel) - // var unproxyableMembers = await _data.GetUnproxyableMembers(ctx.System); - // if (unproxyableMembers.Count > 0) - // { - // var msg = await ctx.Reply( - // $"{Emojis.Warn} Changing your system tag to '{newTag.SanitizeMentions()}' will result in the following members being unproxyable, since the tag would bring their name over {Limits.MaxProxyNameLength} characters:\n**{string.Join(", ", unproxyableMembers.Select((m) => m.Name.SanitizeMentions()))}**\nDo you want to continue anyway?"); - // if (!await ctx.PromptYesNo(msg)) throw new PKError("Tag change cancelled."); - // } - } + if (newTag.Length > Limits.MaxSystemTagLength) + throw Errors.SystemNameTooLongError(newTag.Length); await _data.SaveSystem(ctx.System); await ctx.Reply($"{Emojis.Success} System tag {(newTag != null ? "changed" : "cleared")}."); diff --git a/PluralKit.Core/Models.cs b/PluralKit.Core/Models.cs index eada5940..88f394c7 100644 --- a/PluralKit.Core/Models.cs +++ b/PluralKit.Core/Models.cs @@ -19,9 +19,6 @@ namespace PluralKit [JsonIgnore] public string Token { get; set; } [JsonProperty("created")] public Instant Created { get; set; } [JsonProperty("tz")] public string UiTz { get; set; } - - [JsonIgnore] public int MaxMemberNameLength => Tag != null ? Limits.MaxProxyNameLength - Tag.Length - 1 : Limits.MaxProxyNameLength; - [JsonIgnore] public DateTimeZone Zone => DateTimeZoneProviders.Tzdb.GetZoneOrNull(UiTz); } diff --git a/PluralKit.Core/Stores.cs b/PluralKit.Core/Stores.cs index a9576c69..d97cc84a 100644 --- a/PluralKit.Core/Stores.cs +++ b/PluralKit.Core/Stores.cs @@ -6,7 +6,6 @@ using App.Metrics.Logging; using Dapper; using NodaTime; using Npgsql; -using PluralKit.Core; using Serilog; @@ -52,6 +51,12 @@ namespace PluralKit { public Instant RangeStart; public Instant RangeEnd; } + + public struct SwitchMembersListEntry + { + public int Member; + public Instant Timestamp; + } public interface IDataStore { @@ -466,14 +471,6 @@ namespace PluralKit { return await conn.QueryFirstOrDefaultAsync("select * from members where lower(name) = lower(@Name) and system = @SystemID", new { Name = name, SystemID = system.Id }); } - public async Task> GetUnproxyableMembers(PKSystem system) { - return (await GetSystemMembers(system)) - .Where((m) => { - var proxiedName = $"{m.Name} {system.Tag}"; - return proxiedName.Length > Limits.MaxProxyNameLength || proxiedName.Length < 2; - }).ToList(); - } - public async Task> GetSystemMembers(PKSystem system) { using (var conn = await _conn.Obtain()) return await conn.QueryAsync("select * from members where system = @SystemID", new { SystemID = system.Id }); @@ -676,12 +673,6 @@ namespace PluralKit { return await conn.QueryAsync("select * from switches where system = @System order by timestamp desc limit @Count", new {System = system.Id, Count = count}); } - public struct SwitchMembersListEntry - { - public int Member; - public Instant Timestamp; - } - public async Task> GetSwitchMembersList(PKSystem system, Instant start, Instant end) { // Wrap multiple commands in a single transaction for performance @@ -718,13 +709,6 @@ namespace PluralKit { } } - public async Task> GetSwitchMemberIds(PKSwitch sw) - { - using (var conn = await _conn.Obtain()) - return await conn.QueryAsync("select member from switch_members where switch = @Switch order by switch_members.id", - new {Switch = sw.Id}); - } - public async Task> GetSwitchMembers(PKSwitch sw) { using (var conn = await _conn.Obtain())