Move HasBanExpired to Bans.RemoveBanIfExpired().

The ban system needs a full rewrite anyway, but this move removes
something from Utils, puts it closer to its operating point, simplifies
the method, and clarifies what it actually does.
This commit is contained in:
Lucas Nicodemus 2017-12-29 08:32:45 -07:00
parent f06d1fd238
commit 17d151b8f8
4 changed files with 16 additions and 24 deletions

View file

@ -294,6 +294,20 @@ namespace TShockAPI.DB
}
return false;
}
/// <summary>Removes a ban if it has expired.</summary>
/// <param name="ban">The candidate ban to check.</param>
/// <returns>If the ban has been removed.</returns>
public bool RemoveBanIfExpired(Ban ban)
{
if (!string.IsNullOrWhiteSpace(ban.Expiration) && (ban.ExpirationDateTime != null) && (DateTime.UtcNow >= ban.ExpirationDateTime))
{
RemoveBan(ban.IP, false, false, false);
return true;
}
return false;
}
}
/// <summary>