Небольшой рефакторинг сообщений

This commit is contained in:
upagge 2020-10-11 11:53:39 +03:00
parent 2b49d95412
commit e1c9436a14
No known key found for this signature in database
GPG Key ID: 15CD012E46F6BA34
8 changed files with 18 additions and 17 deletions

View File

@ -26,7 +26,7 @@ bitbucketbot:
no-comment-count: 20 no-comment-count: 20
comment-count: 100 comment-count: 100
init: init:
start-comment-id: 8157 start-comment-id: 8301
use: false use: false
bitbucket: bitbucket:
token: ${BITBUCKET_ADMIN_TOKEN} token: ${BITBUCKET_ADMIN_TOKEN}

View File

@ -37,10 +37,10 @@ public class AnswerCommentNotify extends Notify {
@Override @Override
public String generateMessage() { public String generateMessage() {
final String answerText = answers.stream() 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")); .collect(Collectors.joining("\n\n"));
return MessageFormat.format( return MessageFormat.format(
"{0} *Новые ответы на ваш комментарий* | [ПР]({1}){2}" + "{0} *Новые ответы* на [комментарий]({1}){2}" +
"{3}{2}" + "{3}{2}" +
"{4}", "{4}",
Smile.BELL, Smile.BELL,

View File

@ -37,25 +37,25 @@ public class ReviewersPrNotify extends PrNotify {
final Map<ReviewerChange.Type, List<ReviewerChange>> changes = reviewerChanges.stream() final Map<ReviewerChange.Type, List<ReviewerChange>> changes = reviewerChanges.stream()
.collect(Collectors.groupingBy(ReviewerChange::getType)); .collect(Collectors.groupingBy(ReviewerChange::getType));
if (changes.containsKey(OLD)) { if (changes.containsKey(OLD)) {
stringBuilder.append(Smile.BR).append("Изменили свое решение:").append(Smile.BR);
changes.get(OLD).forEach( changes.get(OLD).forEach(
change -> stringBuilder change -> stringBuilder
.append(Smile.AUTHOR).append(change.getName()).append(": ") .append(Smile.AUTHOR).append(change.getName()).append(": ")
.append(change.getOldStatus().getValue()).append(" -> ") .append(change.getOldStatus().getValue()).append(" ").append(Smile.ARROW).append(" ")
.append(change.getStatus().getValue()) .append(change.getStatus().getValue())
.append(Smile.BR) .append(Smile.BR)
); );
stringBuilder.append(Smile.BR);
} }
if (changes.containsKey(NEW)) { if (changes.containsKey(NEW)) {
stringBuilder.append(Smile.BR).append("Новые ревьюверы:").append(Smile.BR); stringBuilder.append("Новые ревьюверы:").append(Smile.BR);
changes.get(NEW).forEach( changes.get(NEW).forEach(
change -> stringBuilder change -> stringBuilder
.append(change.getName()).append(" (").append(change.getStatus().getValue()).append(")") .append(change.getName()).append(": ").append(change.getStatus().getValue()).append(Smile.BR)
.append(Smile.BR)
); );
stringBuilder.append(Smile.BR);
} }
if (changes.containsKey(DELETED)) { if (changes.containsKey(DELETED)) {
stringBuilder.append(Smile.BR).append("Не выдержали ревью:").append(Smile.BR) stringBuilder.append("Не выдержали ревью:").append(Smile.BR)
.append( .append(
changes.get(DELETED).stream() changes.get(DELETED).stream()
.map(ReviewerChange::getName).collect(Collectors.joining(",")) .map(ReviewerChange::getName).collect(Collectors.joining(","))

View File

@ -33,8 +33,8 @@ public class StatusPrNotify extends PrNotify {
return MessageFormat.format( return MessageFormat.format(
"{0} *Изменился статус вашего ПР*{1}" + "{0} *Изменился статус вашего ПР*{1}" +
"[{2}]({3}){1}" + "[{2}]({3}){1}" +
"{4} -> {5}\n\n", "{4}{5}{6}\n\n",
Smile.PEN, Smile.HR, title, url, oldStatus.name(), newStatus.name() Smile.PEN, Smile.HR, title, url, oldStatus.name(), Smile.ARROW, newStatus.name()
); );
} }

View File

@ -26,8 +26,8 @@ public class TaskCloseNotify extends TaskNotify {
@Override @Override
public String generateMessage() { public String generateMessage() {
return MessageFormat.format( return MessageFormat.format(
"{0} *Задача выполнена* | [ПР]({1}){2}" + "{0} *Закрыта* [задача]({1}){2}" +
"{3}: {4}", "*{3}*: {4}",
Smile.TASK, url, Smile.HR, authorName, escapeMarkdown(messageTask) Smile.TASK, url, Smile.HR, authorName, escapeMarkdown(messageTask)
); );
} }

View File

@ -28,8 +28,8 @@ public class TaskNewNotify extends TaskNotify {
@Override @Override
public String generateMessage() { public String generateMessage() {
return MessageFormat.format( return MessageFormat.format(
"{0} *Назначена новая задача* | [ПР]({1}){2}" + "{0} *Назначена новая* [задача]({1}){2}" +
"{3}: {4}", "*{3}*: {4}",
Smile.TASK, url, Smile.HR, authorName, escapeMarkdown(messageTask) Smile.TASK, url, Smile.HR, authorName, escapeMarkdown(messageTask)
); );
} }

View File

@ -39,7 +39,7 @@ public class NotificationScheduler {
private final AppProperty appProperty; private final AppProperty appProperty;
// Утреннее сообщение // Утреннее сообщение
@Scheduled(cron = "0 */1 * * * *") @Scheduled(cron = "0 15 8 * * MON-FRI")
public void goodMorning() { public void goodMorning() {
List<Person> allRegister = personService.getAllRegister(); List<Person> allRegister = personService.getAllRegister();
for (Person user : allRegister) { for (Person user : allRegister) {
@ -61,7 +61,7 @@ public class NotificationScheduler {
} }
} }
@Scheduled(cron = "0 29 10 * * MON-FRI") @Scheduled(cron = "0 44 10 * * MON-FRI")
public void tks() { public void tks() {
List<Person> usersTks = personService.getAllRegister().stream() List<Person> usersTks = personService.getAllRegister().stream()
.filter(user -> tksLoginNotify.contains(user.getLogin())) .filter(user -> tksLoginNotify.contains(user.getLogin()))

View File

@ -34,6 +34,7 @@ public enum Smile {
LUPA("\uD83D\uDD0D"), LUPA("\uD83D\uDD0D"),
DANGEROUS("⚠️"), DANGEROUS("⚠️"),
BELL("\uD83D\uDECE"), BELL("\uD83D\uDECE"),
ARROW(""),
HR("\n -- -- -- -- --\n"), HR("\n -- -- -- -- --\n"),
FAILURE(""), FAILURE(""),
SUCCESS(""), SUCCESS(""),