From 2d7ee58f1c128e1215285ee058a28386da89688c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Wojtas?= Date: Sun, 1 Feb 2026 17:11:56 +0100 Subject: [PATCH 1/2] Add option to disable pings for users --- .../review/GitHubReviewNotificationType.java | 5 +- .../review/GitHubReviewReminderService.java | 49 ------------------- .../command/child/NotificationChild.java | 1 + 3 files changed, 4 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewNotificationType.java b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewNotificationType.java index c3449439..54d75266 100644 --- a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewNotificationType.java +++ b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewNotificationType.java @@ -4,19 +4,20 @@ public enum GitHubReviewNotificationType { DM, SERVER, + NONE, BOTH; public boolean isDmNotify() { return switch (this) { case DM, BOTH -> true; - case SERVER -> false; + case SERVER, NONE -> false; }; } public boolean isServerNotify() { return switch (this) { case SERVER, BOTH -> true; - case DM -> false; + case DM, NONE -> false; }; } } diff --git a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java index 3a03f24e..0a8bf123 100644 --- a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java +++ b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java @@ -196,17 +196,6 @@ private void handlePRStatusCheck( return; } - this.jda.retrieveUserById(reminder.userId()).queue( - user -> this.handleUserRetrieved( - user, - reminder.threadId(), - reminder.pullRequestUrl(), - pullRequest), - throwable -> { - Sentry.captureException(throwable); - LOGGER.log(Level.SEVERE, "Error retrieving user: " + reminder.userId(), throwable); - } - ); } catch (Exception exception) { Sentry.captureException(exception); @@ -241,42 +230,4 @@ private String findGithubUsernameByDiscordId(long userId) { .orElse(null); } - private void handleUserRetrieved(User user, long threadId, String pullRequestUrl, GitHubPullRequest pullRequest) { - if (user == null) { - LOGGER.warning("User is null for thread: " + threadId); - return; - } - - ThreadChannel thread = this.jda.getThreadChannelById(threadId); - if (thread == null) { - LOGGER.warning("Could not find thread with ID " + threadId); - return; - } - - this.sendReminderMessage(user, thread, pullRequestUrl, pullRequest); - } - - private void sendReminderMessage( - User user, - ThreadChannel thread, - String pullRequestUrl, - GitHubPullRequest pullRequest) { - String message = String.format( - "Hey %s! you have been assigned as a reviewer for this pull request: <%s>.", - user.getAsMention(), - pullRequestUrl - ); - - thread.sendMessage(message).queue( - success -> { - LOGGER.info("Reminder sent to " + user.getName() + " for PR: " + pullRequestUrl); - this.mentionRepository.recordReminderSent(pullRequest, user.getIdLong()) - .exceptionally(FutureHandler::handleException); - }, - throwable -> { - Sentry.captureException(throwable); - LOGGER.log(Level.SEVERE, "Error sending reminder message to " + user.getName(), throwable); - } - ); - } } diff --git a/src/main/java/com/eternalcode/discordapp/review/command/child/NotificationChild.java b/src/main/java/com/eternalcode/discordapp/review/command/child/NotificationChild.java index cc5297c3..1eeccf93 100644 --- a/src/main/java/com/eternalcode/discordapp/review/command/child/NotificationChild.java +++ b/src/main/java/com/eternalcode/discordapp/review/command/child/NotificationChild.java @@ -21,6 +21,7 @@ public NotificationChild(GitHubReviewService gitHubReviewService) { .addChoice("DM", GitHubReviewNotificationType.DM.toString()) .addChoice("SERVER", GitHubReviewNotificationType.SERVER.toString()) .addChoice("BOTH", GitHubReviewNotificationType.BOTH.toString()) + .addChoice("NONE", GitHubReviewNotificationType.NONE.toString()) .setRequired(true) ); From 92c85244385c5fe33f1d34b6483f9a9d232e737c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Wojtas?= Date: Sun, 1 Feb 2026 17:24:30 +0100 Subject: [PATCH 2/2] Rever miss commit --- .../review/GitHubReviewReminderService.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java index 0a8bf123..3a03f24e 100644 --- a/src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java +++ b/src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java @@ -196,6 +196,17 @@ private void handlePRStatusCheck( return; } + this.jda.retrieveUserById(reminder.userId()).queue( + user -> this.handleUserRetrieved( + user, + reminder.threadId(), + reminder.pullRequestUrl(), + pullRequest), + throwable -> { + Sentry.captureException(throwable); + LOGGER.log(Level.SEVERE, "Error retrieving user: " + reminder.userId(), throwable); + } + ); } catch (Exception exception) { Sentry.captureException(exception); @@ -230,4 +241,42 @@ private String findGithubUsernameByDiscordId(long userId) { .orElse(null); } + private void handleUserRetrieved(User user, long threadId, String pullRequestUrl, GitHubPullRequest pullRequest) { + if (user == null) { + LOGGER.warning("User is null for thread: " + threadId); + return; + } + + ThreadChannel thread = this.jda.getThreadChannelById(threadId); + if (thread == null) { + LOGGER.warning("Could not find thread with ID " + threadId); + return; + } + + this.sendReminderMessage(user, thread, pullRequestUrl, pullRequest); + } + + private void sendReminderMessage( + User user, + ThreadChannel thread, + String pullRequestUrl, + GitHubPullRequest pullRequest) { + String message = String.format( + "Hey %s! you have been assigned as a reviewer for this pull request: <%s>.", + user.getAsMention(), + pullRequestUrl + ); + + thread.sendMessage(message).queue( + success -> { + LOGGER.info("Reminder sent to " + user.getName() + " for PR: " + pullRequestUrl); + this.mentionRepository.recordReminderSent(pullRequest, user.getIdLong()) + .exceptionally(FutureHandler::handleException); + }, + throwable -> { + Sentry.captureException(throwable); + LOGGER.log(Level.SEVERE, "Error sending reminder message to " + user.getName(), throwable); + } + ); + } }