diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/entity/MergeRequest.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/entity/MergeRequest.java index b51d692..5867edf 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/entity/MergeRequest.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/entity/MergeRequest.java @@ -57,6 +57,9 @@ public class MergeRequest { @Column(name = "description") private String description; + @Column(name = "milestone") + private String milestone; + @Enumerated(EnumType.STRING) @Column(name = "state") private MergeRequestState state; diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/ConflictMrNotify.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/ConflictMrNotify.java index 311da6e..4dd42cc 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/ConflictMrNotify.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/ConflictMrNotify.java @@ -20,9 +20,10 @@ public class ConflictMrNotify extends MrNotify { String name, String url, String projectKey, - String sourceBranch + String sourceBranch, + String milestone ) { - super(mrId, projectKey, name, url); + super(mrId, projectKey, name, url, milestone); this.sourceBranch = sourceBranch; } diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/ConflictResolveMrNotify.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/ConflictResolveMrNotify.java index 7486f25..2a0c129 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/ConflictResolveMrNotify.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/ConflictResolveMrNotify.java @@ -20,9 +20,10 @@ public class ConflictResolveMrNotify extends MrNotify { String name, String url, String projectKey, - String sourceBranch + String sourceBranch, + String milestone ) { - super(mrId, projectKey, name, url); + super(mrId, projectKey, name, url, milestone); this.sourceBranch = sourceBranch; } diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/MrNotify.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/MrNotify.java index 7fb9e4e..d4c7f0c 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/MrNotify.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/MrNotify.java @@ -10,17 +10,20 @@ public abstract class MrNotify implements Notify { protected final String projectName; protected final String title; protected final String url; + protected final String milestone; protected MrNotify( Long mrId, String projectName, String title, - String url + String url, + String milestone ) { this.mrId = mrId; this.projectName = projectName; this.title = title; this.url = url; + this.milestone = milestone; } } diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/NewMrForAssignee.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/NewMrForAssignee.java index 5c5747f..3a22ebc 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/NewMrForAssignee.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/NewMrForAssignee.java @@ -33,7 +33,8 @@ public class NewMrForAssignee extends NewMrNotify { Set labels, @Singular List reviewers, String oldAssigneeName, - String newAssigneeName + String newAssigneeName, + String milestone ) { super( mrId, @@ -44,7 +45,8 @@ public class NewMrForAssignee extends NewMrNotify { projectName, targetBranch, sourceBranch, - labels + labels, + milestone ); this.reviewers = reviewers; this.oldAssigneeName = oldAssigneeName; diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/NewMrForReview.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/NewMrForReview.java index 74134d5..fe79ebe 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/NewMrForReview.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/NewMrForReview.java @@ -27,7 +27,8 @@ public class NewMrForReview extends NewMrNotify { String targetBranch, String sourceBranch, Set labels, - String assignee + String assignee, + String milestone ) { super( mrId, @@ -38,7 +39,8 @@ public class NewMrForReview extends NewMrNotify { projectName, targetBranch, sourceBranch, - labels + labels, + milestone ); this.assignee = assignee; } diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/NewMrNotify.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/NewMrNotify.java index 20c17ca..2183231 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/NewMrNotify.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/NewMrNotify.java @@ -22,9 +22,10 @@ public abstract class NewMrNotify extends MrNotify { String projectName, String targetBranch, String sourceBranch, - Set labels + Set labels, + String milestone ) { - super(mrId, projectName, title, url); + super(mrId, projectName, title, url, milestone); this.description = description; this.author = author; this.targetBranch = targetBranch; diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/StatusMrNotify.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/StatusMrNotify.java index 743473c..22c80d4 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/StatusMrNotify.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/StatusMrNotify.java @@ -23,9 +23,10 @@ public class StatusMrNotify extends MrNotify { String url, String projectName, MergeRequestState oldStatus, - MergeRequestState newStatus + MergeRequestState newStatus, + String milestone ) { - super(mrId, projectName, name, url); + super(mrId, projectName, name, url, milestone); this.oldStatus = oldStatus; this.newStatus = newStatus; } diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/UpdateMrNotify.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/UpdateMrNotify.java index bb6bd54..61ec84f 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/UpdateMrNotify.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/notify/mergerequest/UpdateMrNotify.java @@ -30,9 +30,10 @@ public class UpdateMrNotify extends MrNotify { Long allResolvedTasks, Long personTasks, Long personResolvedTasks, - String comment + String comment, + String milestone ) { - super(mrId, projectName, name, url); + super(mrId, projectName, name, url, milestone); this.author = author; this.allTasks = allTasks; this.allResolvedTasks = allResolvedTasks; diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/utils/Icons.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/utils/Icons.java index cdbd037..86d0d05 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/utils/Icons.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/utils/Icons.java @@ -22,6 +22,7 @@ public class Icons { public static final String BUILD = "⚙️"; public static final String LINK = "\uD83D\uDD17"; public static final String REVIEWER = "\uD83D\uDD0E"; + public static final String MILESTONE = "\uD83C\uDFAF"; public static final String PROJECT = "\uD83C\uDFD7"; public static final String DISABLE_NOTIFY = "\uD83D\uDD15"; public static final String YES = "✅"; diff --git a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/convert/MergeRequestJsonConverter.java b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/convert/MergeRequestJsonConverter.java index 243b531..d966b17 100644 --- a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/convert/MergeRequestJsonConverter.java +++ b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/convert/MergeRequestJsonConverter.java @@ -43,6 +43,10 @@ public class MergeRequestJsonConverter implements Converter>> tasks = projectIds.stream() .map(projectId -> new GetPipelineShortTask( - gitlabProperty.getPipelineUrl(), + gitlabProperty.getPipelinesUrl(), projectId, lastUpdate, personProperty.getToken() diff --git a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/utils/HttpParse.java b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/utils/HttpParse.java index 227c3e4..e86fed1 100644 --- a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/utils/HttpParse.java +++ b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/utils/HttpParse.java @@ -97,10 +97,10 @@ public class HttpParse { isNotNull(classOfT); final HttpUrl url = httpUrlBuilder.build(); final Request request = requestBuilder.url(url).build(); - log.debug("Выполняется okhttp3 запрос | {}", url); + log.trace("Выполняется okhttp3 запрос | {}", url); final OkHttpClient httpClient = getNewClient(); try (Response execute = httpClient.newCall(request).execute()) { - log.debug("Запрос выполнен | {}", url); + log.trace("Запрос выполнен | {}", url); ResponseBody body = execute.body(); if (execute.isSuccessful() && checkNotNull(body)) { final String stringBody = body.string(); diff --git a/gitlab-app/src/main/resources/liquibase/v.2.0.0/2024-08-21-add-milestone.xml b/gitlab-app/src/main/resources/liquibase/v.2.0.0/2024-08-21-add-milestone.xml new file mode 100644 index 0000000..0686992 --- /dev/null +++ b/gitlab-app/src/main/resources/liquibase/v.2.0.0/2024-08-21-add-milestone.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/gitlab-app/src/main/resources/liquibase/v.2.0.0/changelog.xml b/gitlab-app/src/main/resources/liquibase/v.2.0.0/changelog.xml index 4ba8d94..1f72fec 100644 --- a/gitlab-app/src/main/resources/liquibase/v.2.0.0/changelog.xml +++ b/gitlab-app/src/main/resources/liquibase/v.2.0.0/changelog.xml @@ -8,5 +8,6 @@ + \ No newline at end of file diff --git a/gitlab-sdk/src/main/java/dev/struchkov/bot/gitlab/sdk/domain/MergeRequestJson.java b/gitlab-sdk/src/main/java/dev/struchkov/bot/gitlab/sdk/domain/MergeRequestJson.java index 73b125f..aec5c0b 100644 --- a/gitlab-sdk/src/main/java/dev/struchkov/bot/gitlab/sdk/domain/MergeRequestJson.java +++ b/gitlab-sdk/src/main/java/dev/struchkov/bot/gitlab/sdk/domain/MergeRequestJson.java @@ -41,6 +41,7 @@ public class MergeRequestJson { private PersonJson author; private PersonJson assignee; + private MilestoneJson milestone; private List reviewers; @JsonProperty("web_url") diff --git a/gitlab-sdk/src/main/java/dev/struchkov/bot/gitlab/sdk/domain/MilestoneJson.java b/gitlab-sdk/src/main/java/dev/struchkov/bot/gitlab/sdk/domain/MilestoneJson.java new file mode 100644 index 0000000..dd8c889 --- /dev/null +++ b/gitlab-sdk/src/main/java/dev/struchkov/bot/gitlab/sdk/domain/MilestoneJson.java @@ -0,0 +1,9 @@ +package dev.struchkov.bot.gitlab.sdk.domain; + +import lombok.Data; + +@Data +public class MilestoneJson { + private Long id; + private String title; +} diff --git a/pom.xml b/pom.xml index 6c13369..59dd236 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ 1.0.0-SNAPSHOT - 3.0.2 + 3.0.3 1.1.1 0.0.5 @@ -53,12 +53,12 @@ 3.2.0-M1 - 33.0.0-jre + 33.3.0-jre - 3.12.1 + 3.13.0 - 3.0.1 + 3.1.1 diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/MessageSendTelegramService.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/MessageSendTelegramService.java index 0711799..f185440 100644 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/MessageSendTelegramService.java +++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/MessageSendTelegramService.java @@ -8,6 +8,7 @@ import dev.struchkov.godfather.simple.domain.BoxAnswer; import dev.struchkov.godfather.telegram.main.context.BoxAnswerPayload; import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending; import lombok.NonNull; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.List; @@ -20,6 +21,7 @@ import java.util.stream.Collectors; * * @author upagge 17.09.2020 */ +@Slf4j @Service public class MessageSendTelegramService implements MessageSendService { @@ -45,6 +47,7 @@ public class MessageSendTelegramService implements MessageSendService { final BoxAnswer answer = generator.generate(notify); answer.setRecipientIfNull(personInformation.getTelegramId()); answer.addPayload(BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW, true); + log.debug("Будет отправлено следующее уведомление: {}. Текст: {}", answer, answer.getMessage()); return answer; }) .ifPresent(sending::send); diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/ConflictPrNotifyGenerator.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/ConflictPrNotifyGenerator.java index 4b02579..4066383 100644 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/ConflictPrNotifyGenerator.java +++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/ConflictPrNotifyGenerator.java @@ -14,6 +14,7 @@ import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLin import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; import static dev.struchkov.godfather.telegram.main.context.BoxAnswerPayload.ENABLE_MARKDOWN; +import static dev.struchkov.haiti.utils.Checker.checkNotNull; import static dev.struchkov.haiti.utils.Strings.escapeMarkdown; @Component @@ -26,7 +27,13 @@ public class ConflictPrNotifyGenerator implements NotifyBoxAnswerGenerator reviewers = notify.getReviewers(); if (checkNotEmpty(reviewers)) { builder.append(Icons.REVIEWER).append(": ").append(String.join(", ", reviewers)).append("\n"); diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/NewMrForReviewNotifyGenerator.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/NewMrForReviewNotifyGenerator.java index 41b8064..de9bc7b 100644 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/NewMrForReviewNotifyGenerator.java +++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/NewMrForReviewNotifyGenerator.java @@ -43,6 +43,10 @@ public class NewMrForReviewNotifyGenerator implements NotifyBoxAnswerGenerator { final ButtonClickAttachment clickButton = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow(); - telegramSending.deleteMessage(mail.getFromPersonId(), clickButton.getMessage().getId()); + //TODO [21.08.2024|uPagge]: fixme + telegramSending.deleteMessage(mail.getFromPersonId(), clickButton.getMessage().get().getId()); }) .build(); } diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyMrUnit.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyMrUnit.java index 71fc377..909ab97 100644 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyMrUnit.java +++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyMrUnit.java @@ -77,7 +77,8 @@ public class DisableNotifyMrUnit implements PersonUnitConfiguration { if (confirmation) { mergeRequestsService.notification(false, mrId); - scheduledExecutorService.schedule(() -> telegramSending.deleteMessage(mail.getFromPersonId(), clickButton.getMessage().getId()), 5, TimeUnit.SECONDS); + //TODO [21.08.2024|uPagge]: fixme + scheduledExecutorService.schedule(() -> telegramSending.deleteMessage(mail.getFromPersonId(), clickButton.getMessage().get().getId()), 5, TimeUnit.SECONDS); return replaceBoxAnswer(SUCCESSFULLY_DISABLED); } else { return replaceBoxAnswer( diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyThreadUnit.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyThreadUnit.java index 075802d..ce8d2f2 100644 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyThreadUnit.java +++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyThreadUnit.java @@ -73,7 +73,8 @@ public class DisableNotifyThreadUnit implements PersonUnitConfiguration { if (confirmation) { discussionService.notification(false, discussionId); - scheduledExecutorService.schedule(() -> telegramSending.deleteMessage(mail.getFromPersonId(), clickButton.getMessage().getId()), 5, TimeUnit.SECONDS); + //TODO [21.08.2024|uPagge]: fixme + scheduledExecutorService.schedule(() -> telegramSending.deleteMessage(mail.getFromPersonId(), clickButton.getMessage().get().getId()), 5, TimeUnit.SECONDS); return replaceBoxAnswer(SUCCESSFULLY_DISABLED); } else { return replaceBoxAnswer( diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/flow/InitSettingFlow.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/flow/InitSettingFlow.java index 84a5d5c..bf035d7 100644 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/flow/InitSettingFlow.java +++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/flow/InitSettingFlow.java @@ -24,6 +24,7 @@ import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +import java.util.Optional; import java.util.Set; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -218,6 +219,8 @@ public class InitSettingFlow implements PersonUnitConfiguration { final String personId = mail.getFromPersonId(); final String messageId = Attachments.findFirstButtonClick(mail.getAttachments()) .map(ButtonClickAttachment::getMessage) + //TODO [21.08.2024|uPagge]: fixme + .map(Optional::get) .map(Mail::getId) .orElseThrow(); sending.send( @@ -407,6 +410,8 @@ public class InitSettingFlow implements PersonUnitConfiguration { final String personId = mail.getFromPersonId(); final String messageId = Attachments.findFirstButtonClick(mail.getAttachments()) .map(ButtonClickAttachment::getMessage) + //TODO [21.08.2024|uPagge]: fixme + .map(Optional::get) .map(Message::getId) .orElseThrow(); sending.send(