Fixed connection error when issuing a permanent ban.

This commit is contained in:
flash 2023-07-23 21:45:10 +00:00
parent 903e39ab76
commit dc4989a3cf

View file

@ -189,9 +189,10 @@ namespace SharpChat
}
public void BanUser(ChatUser user, TimeSpan duration, UserDisconnectReason reason = UserDisconnectReason.Kicked) {
if(duration > TimeSpan.Zero)
SendTo(user, new ForceDisconnectPacket(ForceDisconnectReason.Banned, DateTimeOffset.Now + duration));
else
if (duration > TimeSpan.Zero) {
DateTimeOffset expires = duration >= TimeSpan.MaxValue ? DateTimeOffset.MaxValue : DateTimeOffset.Now + duration;
SendTo(user, new ForceDisconnectPacket(ForceDisconnectReason.Banned, expires));
} else
SendTo(user, new ForceDisconnectPacket(ForceDisconnectReason.Kicked));
foreach(ChatConnection conn in Connections)