From 0bb74203ea454a9514b4fe96187a9f4dba0c0133 Mon Sep 17 00:00:00 2001 From: upagge Date: Fri, 16 Oct 2020 09:52:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B8=D0=B4=D0=B5=D0=BD=D1=82=D0=B8=D1=84=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=D1=86=D1=8B=D0=B8=D1=8E=20=D1=80=D0=B5=D0=BF=20=D0=B2=20=D1=83?= =?UTF-8?q?=D0=B2=D0=B5=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notify/pullrequest/ConflictPrNotify.java | 10 ++++++---- .../pullrequest/ForgottenSmartPrNotify.java | 14 ++++++++++---- .../domain/notify/pullrequest/NewPrNotify.java | 11 +++++++---- .../domain/notify/pullrequest/PrNotify.java | 12 +++++++++++- .../notify/pullrequest/ReviewersPrNotify.java | 9 ++++++--- .../notify/pullrequest/SmartPrNotify.java | 16 ++++++++++++---- .../notify/pullrequest/StatusPrNotify.java | 11 +++++++---- .../notify/pullrequest/UpdatePrNotify.java | 12 ++++++++---- .../service/impl/PullRequestsServiceImpl.java | 18 +++++++++++++++++- 9 files changed, 84 insertions(+), 29 deletions(-) diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ConflictPrNotify.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ConflictPrNotify.java index d5e19c2..3ab784c 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ConflictPrNotify.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ConflictPrNotify.java @@ -14,18 +14,20 @@ public class ConflictPrNotify extends PrNotify { private ConflictPrNotify( Set recipients, String name, - String url + String url, + String projectKey, + String repositorySlug ) { - super(recipients, name, url); + super(recipients, projectKey, repositorySlug, name, url); } @Override public String generateMessage() { return MessageFormat.format( - "{0} *Внимание конфликт в ПР*" + + "{0} *Внимание конфликт в ПР | {4} | {5}*" + "{1}" + "[{2}]({3})\n\n", - Smile.DANGEROUS, Smile.HR, title, url + Smile.DANGEROUS, Smile.HR, title, url, projectKey, repositorySlug ); } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ForgottenSmartPrNotify.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ForgottenSmartPrNotify.java index 201e990..1072911 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ForgottenSmartPrNotify.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ForgottenSmartPrNotify.java @@ -16,16 +16,22 @@ import java.util.Set; public class ForgottenSmartPrNotify extends PrNotify { @Builder - protected ForgottenSmartPrNotify(Set recipients, String title, String url) { - super(recipients, title, url); + protected ForgottenSmartPrNotify( + Set recipients, + String title, + String url, + String projectKey, + String repositorySlug + ) { + super(recipients, projectKey, repositorySlug, title, url); } @Override public String generateMessage() { return MessageFormat.format( - "{0} *Напоминание о просмотре PullRequest*" + + "{0} *Напоминание о просмотре PullRequest | {4} | {5}*" + "{3}[{1}]({2})", - Smile.SMART, title, url, Smile.HR + Smile.SMART, title, url, Smile.HR, projectKey, repositorySlug ); } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/NewPrNotify.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/NewPrNotify.java index ef754b1..0139429 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/NewPrNotify.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/NewPrNotify.java @@ -19,8 +19,11 @@ public class NewPrNotify extends PrNotify { String title, String url, String description, - String author) { - super(recipients, title, url); + String author, + String projectKey, + String repositorySlug + ) { + super(recipients, projectKey, repositorySlug, title, url); this.description = description; this.author = author; } @@ -28,12 +31,12 @@ public class NewPrNotify extends PrNotify { @Override public String generateMessage() { return MessageFormat.format( - "{0} *Новый Pull Request*{1}" + + "{0} *Новый PullRequest | {7} | {8}*{1}" + "[{2}]({3})" + "{1}{4}{5}: {6}\n\n", Smile.FUN, Smile.HR, title, url, (description != null && !"".equals(description)) ? escapeMarkdown(description) + Smile.HR : "", - Smile.AUTHOR, author + Smile.AUTHOR, author, projectKey, repositorySlug ); } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/PrNotify.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/PrNotify.java index f41d021..ac5084d 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/PrNotify.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/PrNotify.java @@ -9,11 +9,21 @@ import java.util.Set; @Getter public abstract class PrNotify extends Notify { + protected final String projectKey; + protected final String repositorySlug; protected final String title; protected final String url; - protected PrNotify(Set recipients, String title, String url) { + protected PrNotify( + Set recipients, + String projectKey, + String repositorySlug, + String title, + String url + ) { super(EntityType.PERSON, recipients); + this.projectKey = projectKey; + this.repositorySlug = repositorySlug; this.title = title; this.url = url; } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ReviewersPrNotify.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ReviewersPrNotify.java index 2090b15..054b2d2 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ReviewersPrNotify.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/ReviewersPrNotify.java @@ -24,8 +24,11 @@ public class ReviewersPrNotify extends PrNotify { Set recipients, String title, String url, - List reviewerChanges) { - super(recipients, title, url); + String projectKey, + String repositorySlug, + List reviewerChanges + ) { + super(recipients, projectKey, repositorySlug, title, url); this.reviewerChanges = reviewerChanges; } @@ -60,7 +63,7 @@ public class ReviewersPrNotify extends PrNotify { ); } final String createMessage = stringBuilder.toString(); - return Smile.PEN + " *Изменения ревьюверов | PullRequest*" + + return Smile.PEN + " *Изменения ревьюверов PullRequest | " + projectKey + " | " + repositorySlug + "*" + Smile.HR + "[" + title + "](" + url + ")" + Smile.HR + createMessage; diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/SmartPrNotify.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/SmartPrNotify.java index 33d645b..342d5b5 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/SmartPrNotify.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/SmartPrNotify.java @@ -19,19 +19,27 @@ public class SmartPrNotify extends PrNotify { private final Reviewer reviewerTriggered; @Builder - protected SmartPrNotify(Set recipients, String title, String url, Reviewer reviewerTriggered) { - super(recipients, title, url); + protected SmartPrNotify( + Set recipients, + String title, + String url, + String projectKey, + String repositorySlug, + Reviewer reviewerTriggered + ) { + super(recipients, projectKey, repositorySlug, title, url); this.reviewerTriggered = reviewerTriggered; } @Override public String generateMessage() { return MessageFormat.format( - "{0} *Напоминание о просмотре PullRequest*" + + "{0} *Напоминание о PullRequest | {6} | {7}*" + "{3}[{1}]({2})" + "{3}" + "{4} изменил свое решение на {5}\n\n", - Smile.SMART, title, url, Smile.HR, reviewerTriggered.getPersonLogin(), reviewerTriggered.getStatus().getValue() + Smile.SMART, title, url, Smile.HR, reviewerTriggered.getPersonLogin(), reviewerTriggered.getStatus().getValue(), + projectKey, repositorySlug ); } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/StatusPrNotify.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/StatusPrNotify.java index b2bae05..810fa66 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/StatusPrNotify.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/StatusPrNotify.java @@ -19,9 +19,12 @@ public class StatusPrNotify extends PrNotify { Set recipients, String name, String url, + String projectKey, + String repositorySlug, PullRequestStatus oldStatus, - PullRequestStatus newStatus) { - super(recipients, name, url); + PullRequestStatus newStatus + ) { + super(recipients, projectKey, repositorySlug, name, url); this.oldStatus = oldStatus; this.newStatus = newStatus; } @@ -29,10 +32,10 @@ public class StatusPrNotify extends PrNotify { @Override public String generateMessage() { return MessageFormat.format( - "{0} *Изменился статус вашего ПР*{1}" + + "{0} *Изменился статус PullRequest | {7} | {8}*{1}" + "[{2}]({3}){1}" + "{4} {5} {6}\n\n", - Smile.PEN, Smile.HR, title, url, oldStatus.name(), Smile.ARROW, newStatus.name() + Smile.PEN, Smile.HR, title, url, oldStatus.name(), Smile.ARROW, newStatus.name(), projectKey, repositorySlug ); } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/UpdatePrNotify.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/UpdatePrNotify.java index 8a3e8f2..1d7dfad 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/UpdatePrNotify.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/pullrequest/UpdatePrNotify.java @@ -16,19 +16,23 @@ public class UpdatePrNotify extends PrNotify { private UpdatePrNotify( Set recipients, String name, - String url, String author) { - super(recipients, name, url); + String url, + String author, + String projectKey, + String repositorySlug + ) { + super(recipients, projectKey, repositorySlug, name, url); this.author = author; } @Override public String generateMessage() { return MessageFormat.format( - "{0} *Обновление PullRequest*\n" + + "{0} *Обновление PullRequest | {6} | {7}*{3}" + "[{1}]({2})" + "{3}" + "{4}: {5}\n\n", - Smile.UPDATE, title, url, Smile.HR, Smile.AUTHOR, author + Smile.UPDATE, title, url, Smile.HR, Smile.AUTHOR, author, projectKey, repositorySlug ); } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/PullRequestsServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/PullRequestsServiceImpl.java index d55be3e..54de057 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/PullRequestsServiceImpl.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/PullRequestsServiceImpl.java @@ -80,6 +80,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService