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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user