Remove preemptive warning messages for unproxyable members
The member length limit is now long enough that it's unlikely to hit the cap by accident. An error will still be displayed if you attempt to perform a message proxy.
This commit is contained in:
parent
c8b4d186d8
commit
523469e5e6
@ -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,9 +243,6 @@ 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);
|
||||
|
||||
|
@ -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")}.");
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ using App.Metrics.Logging;
|
||||
using Dapper;
|
||||
using NodaTime;
|
||||
using Npgsql;
|
||||
using PluralKit.Core;
|
||||
|
||||
using Serilog;
|
||||
|
||||
@ -53,6 +52,12 @@ namespace PluralKit {
|
||||
public Instant RangeEnd;
|
||||
}
|
||||
|
||||
public struct SwitchMembersListEntry
|
||||
{
|
||||
public int Member;
|
||||
public Instant Timestamp;
|
||||
}
|
||||
|
||||
public interface IDataStore
|
||||
{
|
||||
/// <summary>
|
||||
@ -466,14 +471,6 @@ namespace PluralKit {
|
||||
return await conn.QueryFirstOrDefaultAsync<PKMember>("select * from members where lower(name) = lower(@Name) and system = @SystemID", new { Name = name, SystemID = system.Id });
|
||||
}
|
||||
|
||||
public async Task<ICollection<PKMember>> 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<IEnumerable<PKMember>> GetSystemMembers(PKSystem system) {
|
||||
using (var conn = await _conn.Obtain())
|
||||
return await conn.QueryAsync<PKMember>("select * from members where system = @SystemID", new { SystemID = system.Id });
|
||||
@ -676,12 +673,6 @@ namespace PluralKit {
|
||||
return await conn.QueryAsync<PKSwitch>("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<IEnumerable<SwitchMembersListEntry>> 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<IEnumerable<int>> GetSwitchMemberIds(PKSwitch sw)
|
||||
{
|
||||
using (var conn = await _conn.Obtain())
|
||||
return await conn.QueryAsync<int>("select member from switch_members where switch = @Switch order by switch_members.id",
|
||||
new {Switch = sw.Id});
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<PKMember>> GetSwitchMembers(PKSwitch sw)
|
||||
{
|
||||
using (var conn = await _conn.Obtain())
|
||||
|
Loading…
Reference in New Issue
Block a user