diff --git a/bitbucket-app/src/main/resources/application-dev.yaml b/bitbucket-app/src/main/resources/application-dev.yaml index 3fcf33b..470c8f4 100644 --- a/bitbucket-app/src/main/resources/application-dev.yaml +++ b/bitbucket-app/src/main/resources/application-dev.yaml @@ -27,7 +27,7 @@ bitbucketbot: comment-count: 100 init: start-comment-id: 8157 - use: true + use: false bitbucket: token: ${BITBUCKET_ADMIN_TOKEN} url-pull-request-open: http://192.168.236.164:7990/rest/api/1.0/dashboard/pull-requests?limit=150&state=OPEN diff --git a/bitbucket-app/src/main/resources/application.yaml b/bitbucket-app/src/main/resources/application.yaml index 7ccb652..e865bae 100644 --- a/bitbucket-app/src/main/resources/application.yaml +++ b/bitbucket-app/src/main/resources/application.yaml @@ -2,4 +2,6 @@ server: port: 8018 telegram-config: bot-username: ${TELEGRAM_BOT_USERNAME} - bot-token: ${TELEGRAM_BOT_TOKEN} \ No newline at end of file + bot-token: ${TELEGRAM_BOT_TOKEN} +bitbucketbot: + version: 2.15.3 \ No newline at end of file diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/config/properties/AppProperty.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/config/properties/AppProperty.java new file mode 100644 index 0000000..376a7bd --- /dev/null +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/config/properties/AppProperty.java @@ -0,0 +1,21 @@ +package org.sadtech.bot.vcs.core.config.properties; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * // TODO: 11.10.2020 Добавить описание. + * + * @author upagge 11.10.2020 + */ +@Getter +@Setter +@Configuration +@ConfigurationProperties(prefix = "bitbucketbot") +public class AppProperty { + + private String version; + +} diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/GoodMorningNotify.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/GoodMorningNotify.java index c171507..3f60ffd 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/GoodMorningNotify.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/GoodMorningNotify.java @@ -25,42 +25,49 @@ public class GoodMorningNotify extends Notify { private final List pullRequestsReviews; private final List pullRequestsNeedWork; + private final String personName; + private final String version; @Builder protected GoodMorningNotify( Set recipients, List pullRequestsReviews, - List pullRequestsNeedWork - ) { + List pullRequestsNeedWork, + String personName, String version) { super(EntityType.PERSON, recipients); this.pullRequestsReviews = pullRequestsReviews; this.pullRequestsNeedWork = pullRequestsNeedWork; + this.personName = personName; + this.version = version; } @Override public String generateMessage() { - StringBuilder message = new StringBuilder().append(Smile.SUN).append(" *Доброе утро* ").append(Smile.SUN).append(Smile.HR); + StringBuilder message = new StringBuilder().append(Smile.SUN).append(" *Доброе утро, ").append(personName).append("* ").append(Smile.SUN).append(Smile.TWO_BR); if (!pullRequestsReviews.isEmpty()) { - message.append("Необходимо проверить ").append(pullRequestsReviews.size()).append(" ПР!").append(Smile.TWO_BR) - .append("Самые старые:").append(Smile.BR); + message.append("Необходимо проверить ").append(pullRequestsReviews.size()).append(" ПР:").append(Smile.BR); MessageUtils.pullRequestForReview( pullRequestsReviews.stream() .limit(3) .collect(Collectors.toList()) ).ifPresent(message::append); } else { - message.append("Ты либо самый лучший работник, либо тебе не доверяют проверку ПР ").append(Smile.MEGA_FUN).append(Smile.TWO_BR) - .append("Поздравляю, у тебя ни одного ПР на проверку!").append(Smile.BR); + message.append("Поздравляю, у тебя ни одного ПР на проверку!").append(Smile.BR); } MessageUtils.pullRequestForNeedWork( pullRequestsNeedWork.stream() .limit(3) .collect(Collectors.toList()) ).ifPresent( - messageNeedWork -> message.append(Smile.BR).append(Smile.DANGEROUS).append("Требуется доработать ").append(pullRequestsNeedWork.size()).append(" ПР:").append(Smile.BR).append(messageNeedWork) + messageNeedWork -> message.append(Smile.TWO_BR) + .append(Smile.DANGEROUS).append(" Требуется доработать ").append(pullRequestsNeedWork.size()).append(" ПР:").append(Smile.BR) + .append(messageNeedWork) + .append(Smile.BR) ); message - .append(Smile.BR).append("Удачного дня ").append(Smile.FLOWER).append(Smile.TWO_BR); + .append(Smile.BR).append("Удачного дня ").append(Smile.FLOWER) + .append(Smile.HR) + .append("_Version ").append(version).append(" | Developer @uPagge_"); return message.toString(); } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/AnswerCommentNotify.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/AnswerCommentNotify.java index b8aee09..ff54804 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/AnswerCommentNotify.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/AnswerCommentNotify.java @@ -37,7 +37,7 @@ public class AnswerCommentNotify extends Notify { @Override public String generateMessage() { final String answerText = answers.stream() - .map(answer -> answer.getAuthorName() + ": " + answer.getMessage().substring(0, Math.min(answer.getMessage().length(), 500))) + .map(answer -> "*" + answer.getAuthorName() + "*: " + answer.getMessage().substring(0, Math.min(answer.getMessage().length(), 500))) .collect(Collectors.joining("\n\n")); return MessageFormat.format( "{0} *Новые ответы на ваш комментарий* | [ПР]({1}){2}" + diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/CommentNotify.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/CommentNotify.java index 29f2e36..99add74 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/CommentNotify.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/domain/notify/comment/CommentNotify.java @@ -35,7 +35,7 @@ public class CommentNotify extends Notify { public String generateMessage() { return MessageFormat.format( "{0} *Новое упоминание* | [ПР]({1}){2}" + - "{3}: {4}", + "*{3}*: {4}", Smile.BELL, url, Smile.HR, authorName, escapeMarkdown(message.replaceAll("@[\\w]+", "")) ); } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/NotificationScheduler.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/NotificationScheduler.java index 9d1e2cd..0bcb1ec 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/NotificationScheduler.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/scheduler/NotificationScheduler.java @@ -1,6 +1,7 @@ package org.sadtech.bot.vcs.core.scheduler; import lombok.RequiredArgsConstructor; +import org.sadtech.bot.vcs.core.config.properties.AppProperty; import org.sadtech.bot.vcs.core.domain.EntityType; import org.sadtech.bot.vcs.core.domain.PullRequestStatus; import org.sadtech.bot.vcs.core.domain.ReviewerStatus; @@ -35,8 +36,10 @@ public class NotificationScheduler { private final NotifyService notifyService; + private final AppProperty appProperty; + // Утреннее сообщение - @Scheduled(cron = "0 15 8 * * MON-FRI") + @Scheduled(cron = "0 */1 * * * *") public void goodMorning() { List allRegister = personService.getAllRegister(); for (Person user : allRegister) { @@ -48,9 +51,11 @@ public class NotificationScheduler { List pullRequestsNeedWork = pullRequestsService.getAllByAuthorAndReviewerStatus(user.getLogin(), ReviewerStatus.UNAPPROVED); notifyService.send( GoodMorningNotify.builder() + .personName(user.getFullName()) .pullRequestsNeedWork(pullRequestsNeedWork) .pullRequestsReviews(pullRequestsReviews) .recipients(Collections.singleton(user.getLogin())) + .version(appProperty.getVersion()) .build() ); } diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/TaskServiceImpl.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/TaskServiceImpl.java index 04d900f..97d4697 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/TaskServiceImpl.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/service/impl/TaskServiceImpl.java @@ -132,8 +132,6 @@ public class TaskServiceImpl extends AbstractSimpleManagerService im oldTask.getAnswers().clear(); oldTask.setAnswers(existsNewAnswersIds); if (!newAnswers.isEmpty()) { - oldTask.getAnswers().clear(); - oldTask.setAnswers(existsNewAnswersIds); notifyService.send( AnswerCommentNotify.builder() .recipients(Collections.singleton(oldTask.getAuthor())) diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/utils/MessageUtils.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/utils/MessageUtils.java index deca071..9b10dcd 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/utils/MessageUtils.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/utils/MessageUtils.java @@ -48,8 +48,7 @@ public final class MessageUtils { private static String generateStringItemPullRequestReview(PullRequest pullRequest) { return Smile.statusPr(pullRequest.getUpdateDate()) + " " + - link(pullRequest.getTitle(), pullRequest.getUrl()) + - Smile.BR; + link(pullRequest.getTitle(), pullRequest.getUrl()); } @NonNull diff --git a/bot-core/src/main/java/org/sadtech/bot/vcs/core/utils/Smile.java b/bot-core/src/main/java/org/sadtech/bot/vcs/core/utils/Smile.java index f33980d..2654b9a 100644 --- a/bot-core/src/main/java/org/sadtech/bot/vcs/core/utils/Smile.java +++ b/bot-core/src/main/java/org/sadtech/bot/vcs/core/utils/Smile.java @@ -31,7 +31,7 @@ public enum Smile { TOP_TWO("\uD83D\uDE0E"), TOP_THREE("\uD83E\uDD49"), KAKASHKA("\uD83D\uDCA9"), - MEGA_FUN("\uD83D\uDE02"), + LUPA("\uD83D\uDD0D"), DANGEROUS("⚠️"), BELL("\uD83D\uDECE"), HR("\n -- -- -- -- --\n"), diff --git a/pom.xml b/pom.xml index 3344f1f..9969fb6 100644 --- a/pom.xml +++ b/pom.xml @@ -148,36 +148,14 @@ ${javax.persistance} - - - - - - - - - - - - - - - - - - - - - - uPagge Struchkov Mark - upagge@ya.ru + upagge@mail.ru