Изменение сообщений в телеге

This commit is contained in:
upagge 2020-09-16 06:56:43 +03:00
parent 42ab851117
commit 6e37dab153
No known key found for this signature in database
GPG Key ID: 15CD012E46F6BA34
4 changed files with 22 additions and 21 deletions

View File

@ -63,7 +63,7 @@ public class ReviewersPrChange extends PrChange {
);
}
final String createMessage = stringBuilder.toString();
return Smile.PEN + " *Изменения ревьюверов PullRequest*" +
return Smile.PEN + " *Изменения ревьюверов | PullRequest*" +
Smile.HR +
"[" + title + "](" + url + ")" + Smile.HR +
createMessage;

View File

@ -26,7 +26,7 @@ import java.util.stream.Collectors;
public class SchedulerNotification {
private static final Set<String> tksLoginNotify = new HashSet<>(Arrays.asList(
"mstruchkov", "drasskazov", "dganin", "emukhin", "ktorgaeva", "imescheryakov", "kkeglev"
"mstruchkov", "dganin", "emukhin", "ktorgaeva", "imescheryakov", "kkeglev"
));
private static final Set<PullRequestStatus> statuses = Collections.singleton(PullRequestStatus.OPEN);

View File

@ -89,24 +89,12 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
public PullRequest update(@NonNull PullRequest pullRequest) {
final PullRequest oldPullRequest = findAndFillId(pullRequest);
if (!oldPullRequest.isConflict() && pullRequest.isConflict()) {
changeService.save(
ConflictPrChange.builder()
.name(pullRequest.getTitle())
.url(pullRequest.getUrl())
.telegramIds(
personService.getAllTelegramIdByLogin(Collections.singleton(pullRequest.getAuthorLogin()))
)
.build()
);
}
oldPullRequest.setBitbucketVersion(pullRequest.getBitbucketVersion());
oldPullRequest.setConflict(pullRequest.isConflict());
oldPullRequest.setTitle(pullRequest.getTitle());
oldPullRequest.setDescription(pullRequest.getDescription());
updateReviewers(oldPullRequest, pullRequest);
updateStatus(oldPullRequest, pullRequest);
updateConflict(oldPullRequest, pullRequest);
final PullRequest newPullRequest = pullRequestsRepository.save(oldPullRequest);
if (!pullRequest.getBitbucketVersion().equals(newPullRequest.getBitbucketVersion())) {
@ -123,6 +111,21 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
return newPullRequest;
}
private void updateConflict(PullRequest oldPullRequest, PullRequest pullRequest) {
if (!oldPullRequest.isConflict() && pullRequest.isConflict()) {
changeService.save(
ConflictPrChange.builder()
.name(pullRequest.getTitle())
.url(pullRequest.getUrl())
.telegramIds(
personService.getAllTelegramIdByLogin(Collections.singleton(pullRequest.getAuthorLogin()))
)
.build()
);
}
oldPullRequest.setConflict(pullRequest.isConflict());
}
private void updateStatus(PullRequest oldPullRequest, PullRequest newPullRequest) {
final PullRequestStatus oldStatus = oldPullRequest.getStatus();
final PullRequestStatus newStatus = newPullRequest.getStatus();

View File

@ -21,13 +21,12 @@ public final class Message {
private static final UpdateDataComparator COMPARATOR = new UpdateDataComparator();
private static final Integer PR_COUNT = 4;
private static final String DONATION_LINK = "https://www.tinkoff.ru/sl/1T9s4esiMf";
private static final String HELP_LINK = "https://nuzhnapomosh.ru/about/";
@NonNull
public static String goodMorningStatistic(List<PullRequest> pullRequestsReviews, List<PullRequest> pullRequestsNeedWork) {
StringBuilder message = new StringBuilder().append(Smile.SUN).append(" Доброе утро ").append(Smile.SUN).append(Smile.HR);
StringBuilder message = new StringBuilder().append(Smile.SUN).append(" *Доброе утро* ").append(Smile.SUN).append(Smile.HR);
if (!pullRequestsReviews.isEmpty()) {
message.append("Сегодня тебя ждет проверка ").append(pullRequestsReviews.size()).append(" ПР!").append(Smile.TWO_BR)
message.append("Необходимо проверить ").append(pullRequestsReviews.size()).append(" ПР!").append(Smile.TWO_BR)
.append("Самые старые:").append(Smile.BR);
List<PullRequest> oldPr = pullRequestsReviews.stream()
.sorted(COMPARATOR)
@ -44,12 +43,11 @@ public final class Message {
}
if (dayX()) {
message.append(Smile.BR).append(Smile.FUN).append(" Кстати, поздравляю, сегодня день З").append(Smile.BR)
.append(Smile.DANGEROUS).append("Спасибо всем, кто ").append(link("донатил", DONATION_LINK)).append(", мы оплатили хостинг до октября :)")
.append(Smile.BR).append("Теперь стоит ").append(link("помочь", HELP_LINK)).append(" тем, кто действительно в этом нуждается))")
.append(Smile.DANGEROUS).append("Хостинг оплачен до 5 октября! Прошу неравнодушных ").append(link("задонатить", DONATION_LINK))
.append(Smile.BR);
}
message
.append("Удачного дня ").append(Smile.FLOWER).append(Smile.TWO_BR);
.append(Smile.BR).append("Удачного дня ").append(Smile.FLOWER).append(Smile.TWO_BR);
return message.toString();
}