From 0e1e7c6cad237102507b2721503401706950cdde Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Wed, 4 Sep 2024 00:16:56 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B2=D0=B5=D0=B4=D0=BE=D0=BC=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D0=B1=20=D0=B8=D0=B7=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=80=D0=B5=D0=B2=D1=8C?= =?UTF-8?q?=D1=8E=D0=B2=D0=B5=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/handler/MergeRequestHandler.java | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/handler/MergeRequestHandler.java b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/handler/MergeRequestHandler.java index 3a4f324..341937f 100644 --- a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/handler/MergeRequestHandler.java +++ b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/handler/MergeRequestHandler.java @@ -68,11 +68,7 @@ public class MergeRequestHandler { } } - if (checkNotEmpty(mergeRequest.getReviewers())) { - sendGroupNotifyForReviewers(mergeRequest, projectName); - } else { - sendGroupNotifyAboutNoReviewers(mergeRequest, projectName); - } + sendGroupNotifyForReviewers(mergeRequest, projectName); } } @@ -116,6 +112,9 @@ public class MergeRequestHandler { if (newConflict) { sendGroupNotifyAboutConflict(newMergeRequest, project.getName()); } + if (reviewerChanged.isChanged()) { + sendGroupNotifyForReviewers(newMergeRequest, project.getName()); + } } @@ -156,22 +155,26 @@ public class MergeRequestHandler { } private void sendGroupNotifyForReviewers(MergeRequest mergeRequest, String projectName) { - final Map reviewerTelegramUsernames = personService.getTelegramUsernamesByPersonIds(mergeRequest.getReviewers().stream().map(Person::getId).collect(Collectors.toSet())); - if (!reviewerTelegramUsernames.isEmpty()) { - notifyService.send( - NewMergeRequestGroupNotify.builder() - .mrId(mergeRequest.getId()) - .title(mergeRequest.getTitle()) - .url(mergeRequest.getWebUrl()) - .author(mergeRequest.getAuthor().getName()) - .reviewerTelegramUsernames(reviewerTelegramUsernames) - .milestone(mergeRequest.getMilestone()) - .projectName(projectName) - .targetBranch(mergeRequest.getTargetBranch()) - .sourceBranch(mergeRequest.getSourceBranch()) - .description(mergeRequest.getDescription()) - .build() - ); + if (checkNotEmpty(mergeRequest.getReviewers())) { + final Map reviewerTelegramUsernames = personService.getTelegramUsernamesByPersonIds(mergeRequest.getReviewers().stream().map(Person::getId).collect(Collectors.toSet())); + if (!reviewerTelegramUsernames.isEmpty()) { + notifyService.send( + NewMergeRequestGroupNotify.builder() + .mrId(mergeRequest.getId()) + .title(mergeRequest.getTitle()) + .url(mergeRequest.getWebUrl()) + .author(mergeRequest.getAuthor().getName()) + .reviewerTelegramUsernames(reviewerTelegramUsernames) + .milestone(mergeRequest.getMilestone()) + .projectName(projectName) + .targetBranch(mergeRequest.getTargetBranch()) + .sourceBranch(mergeRequest.getSourceBranch()) + .description(mergeRequest.getDescription()) + .build() + ); + } + } else { + sendGroupNotifyAboutNoReviewers(mergeRequest, projectName); } }