Fix small bug with ban calculation

If a user had a permaban, there would be a comparison error between the
current time and the expiration time (none).

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-06-26 20:27:42 -07:00
parent fb61239147
commit 356196db26
2 changed files with 5 additions and 5 deletions

View File

@@ -37,8 +37,8 @@ def is_banned(ip: str, board: Optional["Board"]) -> bool:
now = timezone.now()
bans = [ban for ban in get_ip_bans(ip) if ban.board == board or not ban.board]
if bans:
active = [ban for ban in bans if ban.expires > now]
expired = [ban for ban in bans if ban.expires <= now]
active = [ban for ban in bans if not ban.expires or ban.expires > now]
expired = [ban for ban in bans if ban.expires and ban.expires <= now]
# Delete expired bans
for ban in expired:
ban.delete()