From da15cda817105f5169434e0cd248cc23c13ab7b2 Mon Sep 17 00:00:00 2001 From: Askaholic Date: Wed, 27 Dec 2023 13:53:30 -0500 Subject: [PATCH] Change ban errors to use 'kick' style This signals to the client that it should close itself. --- server/lobbyconnection.py | 4 +++- tests/integration_tests/test_login.py | 4 ++-- tests/integration_tests/test_server.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/lobbyconnection.py b/server/lobbyconnection.py index 690b77aa6..def89a87e 100644 --- a/server/lobbyconnection.py +++ b/server/lobbyconnection.py @@ -184,7 +184,9 @@ async def on_message_received(self, message): except BanError as e: await self.send({ "command": "notice", - "style": "error", + # Tell the client to close itself. This prevents it from getting + # stuck in an auto-reconnect loop. + "style": "kick", "text": e.message() }) await self.abort(e.message()) diff --git a/tests/integration_tests/test_login.py b/tests/integration_tests/test_login.py index 1371c62d2..739e92fc9 100644 --- a/tests/integration_tests/test_login.py +++ b/tests/integration_tests/test_login.py @@ -38,7 +38,7 @@ async def test_server_ban(lobby_server, user): msg = await proto.read_message() assert msg == { "command": "notice", - "style": "error", + "style": "kick", "text": ( "You are banned from FAF forever.
Reason:
Test permanent ban" "

If you would like to appeal this ban, please send an " @@ -73,7 +73,7 @@ async def test_server_ban_token(lobby_server, user, jwk_priv_key, jwk_kid): msg = await proto.read_message() assert msg == { "command": "notice", - "style": "error", + "style": "kick", "text": ( "You are banned from FAF forever.
Reason:
Test permanent ban" "

If you would like to appeal this ban, please send an " diff --git a/tests/integration_tests/test_server.py b/tests/integration_tests/test_server.py index 850e4ade3..8854509de 100644 --- a/tests/integration_tests/test_server.py +++ b/tests/integration_tests/test_server.py @@ -727,7 +727,7 @@ async def test_server_ban_prevents_hosting(lobby_server, database, command): msg = await proto.read_message() assert msg == { "command": "notice", - "style": "error", + "style": "kick", "text": ( "You are banned from FAF forever.
Reason:
Test live ban
" "
If you would like to appeal this ban, please send an email "