diff --git a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/entity/Discussion.java b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/entity/Discussion.java index 16b8cfd..dd07c32 100644 --- a/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/entity/Discussion.java +++ b/bot-context/src/main/java/dev/struchkov/bot/gitlab/context/domain/entity/Discussion.java @@ -100,5 +100,14 @@ public class Discussion { return Optional.empty(); } + public Optional getLastNoteByUserId(Long personId) { + for (int i = notes.size() - 1; i >= 0; i--) { + final Note note = notes.get(i); + if (note.getAuthor().getId().equals(personId)) { + return Optional.of(note); + } + } + return Optional.empty(); + } } diff --git a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/impl/DiscussionServiceImpl.java b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/impl/DiscussionServiceImpl.java index 9114814..f795710 100644 --- a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/impl/DiscussionServiceImpl.java +++ b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/impl/DiscussionServiceImpl.java @@ -321,6 +321,7 @@ public class DiscussionServiceImpl implements DiscussionService { if (NOTIFY_WITH_CONTEXT.equals(discussionLevel)) { final Optional prevLastNote = discussion.getPrevLastNote(); + if (prevLastNote.isPresent()) { final Note prevNote = prevLastNote.get(); notifyBuilder.previousMessage(prevNote.getBody()); 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 b65404e..1e6d41b 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 @@ -5,6 +5,7 @@ import dev.struchkov.bot.gitlab.context.domain.notify.Notify; import dev.struchkov.bot.gitlab.context.service.MessageSendService; import dev.struchkov.bot.gitlab.telegram.service.notify.NotifyBoxAnswerGenerator; 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 org.springframework.stereotype.Service; @@ -43,6 +44,7 @@ public class MessageSendTelegramService implements MessageSendService { .map(generator -> { final BoxAnswer answer = generator.generate(notify); answer.setRecipientIfNull(personInformation.getTelegramId()); + answer.setPayload(BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW, true); return answer; }) .ifPresent(sending::send); diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/NewCommentNotifyGenerator.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/NewCommentNotifyGenerator.java index 4d082ce..c645927 100644 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/NewCommentNotifyGenerator.java +++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/NewCommentNotifyGenerator.java @@ -14,6 +14,7 @@ import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.s import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; +import static dev.struchkov.haiti.utils.Checker.checkNotBlank; import static dev.struchkov.haiti.utils.Checker.checkNotNull; import static dev.struchkov.haiti.utils.Strings.escapeMarkdown; @@ -23,8 +24,15 @@ public class NewCommentNotifyGenerator implements NotifyBoxAnswerGenerator> notes = notify.getNotes(); if (checkNotEmpty(notes)) {