From bcedc5c8188b14f3497be5fb637f64daddcdea16 Mon Sep 17 00:00:00 2001 From: Dan Van Atta Date: Mon, 29 Jul 2024 13:34:27 -0700 Subject: [PATCH] Cleanup: remove unused chat-upload files (#12794) * Remove unused files that were recently moved * Remove unused files --- http-clients/game-support-server/build.gradle | 8 --- .../report/CanUploadErrorReportResponse.java | 29 ---------- .../client/error/report/CanUploadRequest.java | 19 ------- .../error/report/ErrorReportClient.java | 34 ------------ .../error/report/ErrorReportRequest.java | 55 ------------------- .../error/report/ErrorReportResponse.java | 22 -------- .../game/lobby/watcher/ChatMessageUpload.java | 21 ------- .../game/lobby/watcher/ChatUploadParams.java | 25 --------- 8 files changed, 213 deletions(-) delete mode 100644 http-clients/game-support-server/build.gradle delete mode 100644 http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/CanUploadErrorReportResponse.java delete mode 100644 http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/CanUploadRequest.java delete mode 100644 http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/ErrorReportClient.java delete mode 100644 http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/ErrorReportRequest.java delete mode 100644 http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/ErrorReportResponse.java delete mode 100644 http-clients/lobby-client/src/main/java/org/triplea/http/client/lobby/game/lobby/watcher/ChatMessageUpload.java delete mode 100644 http-clients/lobby-client/src/main/java/org/triplea/http/client/lobby/game/lobby/watcher/ChatUploadParams.java diff --git a/http-clients/game-support-server/build.gradle b/http-clients/game-support-server/build.gradle deleted file mode 100644 index a855d6c0e49..00000000000 --- a/http-clients/game-support-server/build.gradle +++ /dev/null @@ -1,8 +0,0 @@ -dependencies { - implementation "io.github.openfeign:feign-core:$feignVersion" - implementation "io.github.openfeign:feign-gson:$feignVersion" - implementation project(":lib:feign-common") - implementation project(":lib:java-extras") - testImplementation "ru.lanwen.wiremock:wiremock-junit5:$wireMockJunit5Version" - testImplementation project(":lib:test-common") -} diff --git a/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/CanUploadErrorReportResponse.java b/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/CanUploadErrorReportResponse.java deleted file mode 100644 index 9eff38955d4..00000000000 --- a/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/CanUploadErrorReportResponse.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.triplea.http.client.error.report; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.ToString; - -@ToString -@Builder -@Getter -@EqualsAndHashCode -public class CanUploadErrorReportResponse { - /** - * True means a user can upload an error report. False means an error report is already uploaded. - * If true, then responseDetails and existingBugReportUrl will be null. - */ - @Nonnull private final Boolean canUpload; - - /** - * Contains any message details that should be displayed to the user. EG: "This error is already - * uploaded" - */ - @Nullable private final String responseDetails; - - /** Contains a link to any existing error report that matches the same error the user sees. */ - @Nullable private final String existingBugReportUrl; -} diff --git a/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/CanUploadRequest.java b/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/CanUploadRequest.java deleted file mode 100644 index 4cba5064f5c..00000000000 --- a/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/CanUploadRequest.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.triplea.http.client.error.report; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.ToString; - -@ToString -@EqualsAndHashCode -@Builder -@NoArgsConstructor -@AllArgsConstructor -@Getter -public class CanUploadRequest { - private String gameVersion; - private String errorTitle; -} diff --git a/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/ErrorReportClient.java b/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/ErrorReportClient.java deleted file mode 100644 index d1aed83d477..00000000000 --- a/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/ErrorReportClient.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.triplea.http.client.error.report; - -import feign.FeignException; -import feign.RequestLine; -import java.net.URI; -import org.triplea.http.client.HttpClient; -import org.triplea.http.client.lib.ClientIdentifiers; - -/** Http client to upload error reports to the http lobby server. */ -public interface ErrorReportClient { - String ERROR_REPORT_PATH = "/game-support/error-report"; - String CAN_UPLOAD_ERROR_REPORT_PATH = "/game-support/error-report-check"; - int MAX_REPORTS_PER_DAY = 5; - - /** Creates an error report uploader clients, sends error reports and gets a response back. */ - static ErrorReportClient newClient(URI uri, ClientIdentifiers clientIdentifiers) { - return HttpClient.newClient(ErrorReportClient.class, uri, clientIdentifiers.createHeaders()); - } - - /** - * API to upload an exception error report from a TripleA client to TripleA server. - * - * @throws FeignException Thrown on non-2xx responses. - */ - @RequestLine("POST " + ErrorReportClient.ERROR_REPORT_PATH) - ErrorReportResponse uploadErrorReport(ErrorReportRequest request); - - /** - * Checks if user can upload a request. A request can be uploaded if: - it has not yet been - * reported - reporting version is greater than fix version - user is not banned - */ - @RequestLine("POST " + ErrorReportClient.CAN_UPLOAD_ERROR_REPORT_PATH) - CanUploadErrorReportResponse canUploadErrorReport(CanUploadRequest canUploadRequest); -} diff --git a/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/ErrorReportRequest.java b/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/ErrorReportRequest.java deleted file mode 100644 index d12c8344e4d..00000000000 --- a/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/ErrorReportRequest.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.triplea.http.client.error.report; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.annotation.Nonnull; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.ToString; -import org.triplea.http.client.HttpClientConstants; -import org.triplea.java.StringUtils; - -/** Represents data that would be uploaded to a server. */ -@ToString -@EqualsAndHashCode -@Builder(toBuilder = true) -@NoArgsConstructor -@AllArgsConstructor -public class ErrorReportRequest { - /** - * GAME_VERSION_MAJOR_MINOR regex matches first digits, and optional;u a dot followed by more - * digits. Examples:
- * 1.1 -> 1.1
- * 2.3.1 -> 2.3
- * 10 -> 10
- * 2.3+1 -> 3.2
- * Of note, we have a variety of matches to account for old version formats and to handle possible - * future variety of versions. - */ - private static final Pattern GAME_VERSION_MAJOR_MINOR = Pattern.compile("^[0-9]+(\\.[0-9]+)?"); - - @Nonnull private String title; - @Nonnull private String body; - @Nonnull @Getter private String gameVersion; - - public String getTitle() { - return StringUtils.truncate(title, HttpClientConstants.TITLE_MAX_LENGTH); - } - - public String getBody() { - return StringUtils.truncate(body, HttpClientConstants.REPORT_BODY_MAX_LENGTH); - } - - /** - * Returns the 'major.minor' part of the game version, eg: "2.6+123" -> "2.6". If the gameVersion - * value is in an unexpected format, we return the gameVersion value as-is. - */ - public String getSimpleGameVersion() { - Matcher m = GAME_VERSION_MAJOR_MINOR.matcher(gameVersion); - // return the matched part if found, otherwise just return 'gameVersion' as-is - return m.find() ? m.group() : gameVersion; - } -} diff --git a/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/ErrorReportResponse.java b/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/ErrorReportResponse.java deleted file mode 100644 index 3bc09fdd8c0..00000000000 --- a/http-clients/game-support-server/src/main/java/org/triplea/http/client/error/report/ErrorReportResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.triplea.http.client.error.report; - -import javax.annotation.Nonnull; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.ToString; - -/** Data object that corresponds to the JSON response from lobby-server for error report. */ -@ToString -@Builder -@Getter -@EqualsAndHashCode -@AllArgsConstructor -public class ErrorReportResponse { - /** - * A link to the github issue created (empty if there were problems creating the link). Server - * should return a 500 in case there are any problems creating the error report. - */ - @Nonnull private final String githubIssueLink; -} diff --git a/http-clients/lobby-client/src/main/java/org/triplea/http/client/lobby/game/lobby/watcher/ChatMessageUpload.java b/http-clients/lobby-client/src/main/java/org/triplea/http/client/lobby/game/lobby/watcher/ChatMessageUpload.java deleted file mode 100644 index ba372ee6f0a..00000000000 --- a/http-clients/lobby-client/src/main/java/org/triplea/http/client/lobby/game/lobby/watcher/ChatMessageUpload.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.triplea.http.client.lobby.game.lobby.watcher; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.ToString; - -/** Data transfer object between client and server representing a single chat message upload. */ -@Builder -@AllArgsConstructor -@NoArgsConstructor -@Getter -@EqualsAndHashCode -@ToString -public class ChatMessageUpload { - private String fromPlayer; - private String chatMessage; - private String gameId; -} diff --git a/http-clients/lobby-client/src/main/java/org/triplea/http/client/lobby/game/lobby/watcher/ChatUploadParams.java b/http-clients/lobby-client/src/main/java/org/triplea/http/client/lobby/game/lobby/watcher/ChatUploadParams.java deleted file mode 100644 index 531fa34eb55..00000000000 --- a/http-clients/lobby-client/src/main/java/org/triplea/http/client/lobby/game/lobby/watcher/ChatUploadParams.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.triplea.http.client.lobby.game.lobby.watcher; - -import lombok.Builder; -import lombok.Value; -import org.triplea.domain.data.UserName; - -/** - * Parameter object for uploading a chat message, this object is *not* transferred over the wire, - * {@see ChatMessageUpload}. - */ -@Value -@Builder -public class ChatUploadParams { - UserName fromPlayer; - String chatMessage; - String gameId; - - ChatMessageUpload toChatMessageUpload() { - return ChatMessageUpload.builder() - .fromPlayer(fromPlayer.getValue()) - .chatMessage(chatMessage) - .gameId(gameId) - .build(); - } -}