From 0147a1d41f5e113719dfff0aa7aa521f79f07e64 Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Sun, 7 Sep 2025 17:58:52 +0200 Subject: [PATCH] disallow users on your ignore list to get your current games (#6109) --- cockatrice/src/server/user/user_context_menu.cpp | 15 ++++++++++++++- common/server_protocolhandler.cpp | 11 +++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/server/user/user_context_menu.cpp b/cockatrice/src/server/user/user_context_menu.cpp index 86fa4a8bf..544590828 100644 --- a/cockatrice/src/server/user/user_context_menu.cpp +++ b/cockatrice/src/server/user/user_context_menu.cpp @@ -79,8 +79,21 @@ void UserContextMenu::retranslateUi() void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer) { - const Response_GetGamesOfUser &response = resp.GetExtension(Response_GetGamesOfUser::ext); const Command_GetGamesOfUser &cmd = commandContainer.session_command(0).GetExtension(Command_GetGamesOfUser::ext); + if (resp.response_code() == Response::RespNameNotFound) { + QMessageBox::critical(static_cast(parent()), tr("Error"), tr("This user does not exist.")); + return; + } else if (resp.response_code() == Response::RespInIgnoreList) { + QMessageBox::critical( + static_cast(parent()), tr("Error"), + tr("You are being ignored by %1 and can't see their games.").arg(QString::fromStdString(cmd.user_name()))); + return; + } else if (resp.response_code() != Response::RespOk) { + QMessageBox::critical(static_cast(parent()), tr("Error"), + tr("Could not get %1's games.").arg(QString::fromStdString(cmd.user_name()))); + return; + } + const Response_GetGamesOfUser &response = resp.GetExtension(Response_GetGamesOfUser::ext); QMap gameTypeMap; QMap roomMap; diff --git a/common/server_protocolhandler.cpp b/common/server_protocolhandler.cpp index d69ff9ba0..8fa3dc414 100644 --- a/common/server_protocolhandler.cpp +++ b/common/server_protocolhandler.cpp @@ -602,6 +602,17 @@ Response::ResponseCode Server_ProtocolHandler::cmdGetGamesOfUser(const Command_G if (authState == NotLoggedIn) return Response::RespLoginNeeded; + // Do not show games to someone on the ignore list of that user, except for mods + QString target_user = nameFromStdString(cmd.user_name()); + Server_AbstractUserInterface *userInterface = server->findUser(target_user); + if (!userInterface) { + return Response::RespNameNotFound; + } + if (!(userInfo->user_level() & (ServerInfo_User::IsModerator | ServerInfo_User::IsAdmin)) && + databaseInterface->isInIgnoreList(target_user, QString::fromStdString(userInfo->name()))) { + return Response::RespInIgnoreList; + } + // We don't need to check whether the user is logged in; persistent games should also work. // The client needs to deal with an empty result list.