From aadd1d12ee6c17559694a8f145d9a91a06af8840 Mon Sep 17 00:00:00 2001 From: DanVanAtta Date: Fri, 26 Jul 2024 13:50:35 -0700 Subject: [PATCH] Remove moderator right click option "fetch game chat history" We are no longer uploading chat messages from hosted (bot or player) games to lobby. This update removes the 'fetch game chat history' feature since that data will always be blank going forward. --- .../lobby/client/ui/LobbyGamePanel.java | 17 ----- .../client/ui/action/FetchChatHistory.java | 74 ------------------- .../lobby/moderator/ModeratorLobbyClient.java | 5 -- .../connections/PlayerToLobbyConnection.java | 5 -- 4 files changed, 101 deletions(-) delete mode 100644 game-app/game-headed/src/main/java/games/strategy/engine/lobby/client/ui/action/FetchChatHistory.java diff --git a/game-app/game-headed/src/main/java/games/strategy/engine/lobby/client/ui/LobbyGamePanel.java b/game-app/game-headed/src/main/java/games/strategy/engine/lobby/client/ui/LobbyGamePanel.java index 045a22ad0fd..f02db66ac70 100644 --- a/game-app/game-headed/src/main/java/games/strategy/engine/lobby/client/ui/LobbyGamePanel.java +++ b/game-app/game-headed/src/main/java/games/strategy/engine/lobby/client/ui/LobbyGamePanel.java @@ -3,7 +3,6 @@ import games.strategy.engine.framework.GameProcess; import games.strategy.engine.framework.startup.ui.ServerOptions; import games.strategy.engine.lobby.client.login.LoginResult; -import games.strategy.engine.lobby.client.ui.action.FetchChatHistory; import games.strategy.engine.lobby.client.ui.action.ShowPlayersAction; import games.strategy.triplea.settings.ClientSetting; import java.awt.BorderLayout; @@ -194,7 +193,6 @@ private void mouseOnGamesList(final MouseEvent mouseEvent) { if (loginResult.isModerator()) { menu.addSeparator(); List.of( - SwingAction.of("Show Chat History", e -> showChatHistory()), SwingAction.of("Boot Game", e -> bootGame()), SwingAction.of("Shutdown", e -> shutdown())) .forEach(menu::add); @@ -234,21 +232,6 @@ private void hostGame() { ClientSetting.lobbyUri.getValueOrThrow()); } - private void showChatHistory() { - final int selectedIndex = gameTable.getSelectedRow(); - if (selectedIndex == -1) { - return; - } - - FetchChatHistory.builder() - .parentWindow(parent) - .gameId(gameTableModel.getGameIdForRow(gameTable.convertRowIndexToModel(selectedIndex))) - .gameHostName(gameTableModel.get(selectedIndex).getHostedBy().getName()) - .playerToLobbyConnection(playerToLobbyConnection) - .build() - .fetchAndShowChatHistory(); - } - private void bootGame() { final int selectedIndex = gameTable.getSelectedRow(); if (selectedIndex == -1) { diff --git a/game-app/game-headed/src/main/java/games/strategy/engine/lobby/client/ui/action/FetchChatHistory.java b/game-app/game-headed/src/main/java/games/strategy/engine/lobby/client/ui/action/FetchChatHistory.java deleted file mode 100644 index 56ec47cffe8..00000000000 --- a/game-app/game-headed/src/main/java/games/strategy/engine/lobby/client/ui/action/FetchChatHistory.java +++ /dev/null @@ -1,74 +0,0 @@ -package games.strategy.engine.lobby.client.ui.action; - -import java.awt.Component; -import java.time.Instant; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import javax.swing.JFrame; -import javax.swing.SwingUtilities; -import lombok.Builder; -import lombok.extern.slf4j.Slf4j; -import org.triplea.http.client.lobby.moderator.ChatHistoryMessage; -import org.triplea.http.client.web.socket.client.connections.PlayerToLobbyConnection; -import org.triplea.java.DateTimeFormatterUtil; -import org.triplea.swing.JDialogBuilder; -import org.triplea.swing.JTextAreaBuilder; -import org.triplea.swing.SwingComponents; - -/** - * Does an async call to server to fetch chat history for a given game and then renders the returned - * results in a dialog box. - */ -@Builder -@Slf4j -public class FetchChatHistory { - @Nonnull private final String gameHostName; - @Nonnull private final String gameId; - @Nonnull private final JFrame parentWindow; - @Nonnull private final PlayerToLobbyConnection playerToLobbyConnection; - - public void fetchAndShowChatHistory() { - CompletableFuture.runAsync( - () -> { - final List chatHistory = - playerToLobbyConnection.fetchChatHistoryForGame(gameId); - SwingUtilities.invokeLater(() -> showChatHistory(chatHistory)); - }) - .exceptionally( - e -> { - log.error("Error fetching game chat history", e); - return null; - }); - } - - private void showChatHistory(final List chatHistory) { - new JDialogBuilder() - .parent(parentWindow) - .size(700, 500) - .title( - String.format( - "Game Chat History for: %s, as of %s", - gameHostName, DateTimeFormatterUtil.formatInstant(Instant.now()))) - .add(SwingComponents.newJScrollPane(buildChatHistoryTextArea(chatHistory))) - .buildAndShow(); - } - - private Component buildChatHistoryTextArea(final List chatHistory) { - final String text = - chatHistory.stream() // - .map(FetchChatHistory::toChatLine) - .collect(Collectors.joining("\n")); - - return new JTextAreaBuilder().text(text).readOnly().build(); - } - - private static String toChatLine(final ChatHistoryMessage chatHistoryMessage) { - return String.format( - "(%s) %s: %s", - DateTimeFormatterUtil.formatEpochMilli(chatHistoryMessage.getEpochMilliDate()), - chatHistoryMessage.getUsername(), - chatHistoryMessage.getMessage()); - } -} diff --git a/http-clients/lobby-client/src/main/java/org/triplea/http/client/lobby/moderator/ModeratorLobbyClient.java b/http-clients/lobby-client/src/main/java/org/triplea/http/client/lobby/moderator/ModeratorLobbyClient.java index b46eda53f0b..e9da76e8385 100644 --- a/http-clients/lobby-client/src/main/java/org/triplea/http/client/lobby/moderator/ModeratorLobbyClient.java +++ b/http-clients/lobby-client/src/main/java/org/triplea/http/client/lobby/moderator/ModeratorLobbyClient.java @@ -2,7 +2,6 @@ import feign.RequestLine; import java.net.URI; -import java.util.List; import org.triplea.domain.data.ApiKey; import org.triplea.domain.data.PlayerChatId; import org.triplea.http.client.HttpClient; @@ -13,7 +12,6 @@ public interface ModeratorLobbyClient { String DISCONNECT_PLAYER_PATH = "/lobby/moderator/disconnect-player"; String BAN_PLAYER_PATH = "/lobby/moderator/ban-player"; String MUTE_USER = "/lobby/moderator/mute-player"; - String FETCH_GAME_CHAT_HISTORY = "/lobby/moderator/fetch-game-chat-history"; static ModeratorLobbyClient newClient(final URI lobbyUri, final ApiKey apiKey) { return HttpClient.newClient( @@ -26,9 +24,6 @@ static ModeratorLobbyClient newClient(final URI lobbyUri, final ApiKey apiKey) { @RequestLine("POST " + ModeratorLobbyClient.DISCONNECT_PLAYER_PATH) void disconnectPlayer(String value); - @RequestLine("POST " + ModeratorLobbyClient.FETCH_GAME_CHAT_HISTORY) - List fetchChatHistoryForGame(String gameId); - @RequestLine("POST " + ModeratorLobbyClient.MUTE_USER) void muteUser(MuteUserRequest muteUserRequest); diff --git a/http-clients/lobby-client/src/main/java/org/triplea/http/client/web/socket/client/connections/PlayerToLobbyConnection.java b/http-clients/lobby-client/src/main/java/org/triplea/http/client/web/socket/client/connections/PlayerToLobbyConnection.java index 9433c16345e..01b24726574 100644 --- a/http-clients/lobby-client/src/main/java/org/triplea/http/client/web/socket/client/connections/PlayerToLobbyConnection.java +++ b/http-clients/lobby-client/src/main/java/org/triplea/http/client/web/socket/client/connections/PlayerToLobbyConnection.java @@ -16,7 +16,6 @@ import org.triplea.http.client.lobby.game.lobby.watcher.GameListingClient; import org.triplea.http.client.lobby.game.lobby.watcher.LobbyGameListing; import org.triplea.http.client.lobby.moderator.BanPlayerRequest; -import org.triplea.http.client.lobby.moderator.ChatHistoryMessage; import org.triplea.http.client.lobby.moderator.PlayerSummary; import org.triplea.http.client.lobby.moderator.toolbox.ModeratorToolboxClient; import org.triplea.http.client.web.socket.GenericWebSocketClient; @@ -140,10 +139,6 @@ public void mutePlayer(final PlayerChatId playerChatId, final long minutes) { httpLobbyClient.getModeratorLobbyClient().muteUser(playerChatId, minutes); } - public List fetchChatHistoryForGame(final String gameId) { - return httpLobbyClient.getModeratorLobbyClient().fetchChatHistoryForGame(gameId); - } - public Collection fetchPlayersInGame(final String gameId) { return httpLobbyClient.getPlayerLobbyActionsClient().fetchPlayersInGame(gameId); }