From d8a81c99783e21b525b6feef7778a6ca5dffccf7 Mon Sep 17 00:00:00 2001 From: Tim Raaymakers <43066279+timraay@users.noreply.github.com> Date: Wed, 4 Sep 2024 21:13:26 +0200 Subject: [PATCH] Fix Barricade SCAN_PLAYERS and NEW_REPORT commands (#674) --- rcon/barricade.py | 17 ++++++++++++++++- rcon/blacklist.py | 2 +- rconweb/api/barricade.py | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/rcon/barricade.py b/rcon/barricade.py index f8ef95ba8..e13abd80a 100644 --- a/rcon/barricade.py +++ b/rcon/barricade.py @@ -2,8 +2,23 @@ from channels.layers import get_channel_layer from datetime import datetime from enum import Enum +import os import pydantic +from django.conf import settings as django_settings +django_settings.configure(CHANNEL_LAYERS = { + "default": { + "BACKEND": "channels_redis.core.RedisChannelLayer", + "CONFIG": { + "hosts": [ + { + "address": os.getenv("HLL_REDIS_URL"), + } + ], + }, + }, +}) + GROUP_NAME = "barricade" @@ -63,7 +78,7 @@ class UnbanPlayersRequestPayload(pydantic.BaseModel): class NewReportRequestPayloadPlayer(pydantic.BaseModel): - player_id: int + player_id: str player_name: str bm_rcon_url: str | None diff --git a/rcon/blacklist.py b/rcon/blacklist.py index 79f7d0342..05c8b6920 100644 --- a/rcon/blacklist.py +++ b/rcon/blacklist.py @@ -1224,5 +1224,5 @@ def handle_barricade_warn_online( if online_player_ids: send_to_barricade( request_type=ServerRequestType.SCAN_PLAYERS, - payload=ScanPlayersRequestPayload(player_ids=online_player_ids), + payload=ScanPlayersRequestPayload(player_ids=online_player_ids).model_dump(), ) diff --git a/rconweb/api/barricade.py b/rconweb/api/barricade.py index c0788816b..1adde225b 100644 --- a/rconweb/api/barricade.py +++ b/rconweb/api/barricade.py @@ -327,9 +327,10 @@ async def new_report(self, payload: NewReportRequestPayload): BlacklistCommandHandler.send( BlacklistCommand( command=BlacklistCommandType.BARRICADE_WARN_ONLINE, + server_mask=None, payload=BlacklistBarricadeWarnOnlineCommand( player_ids=[player.player_id for player in payload.players] - ), + ).model_dump(), ) )