diff --git a/telegram-context/telegram-context-main/src/main/java/dev/struchkov/godfather/telegram/main/context/convert/CallbackQueryConvert.java b/telegram-context/telegram-context-main/src/main/java/dev/struchkov/godfather/telegram/main/context/convert/CallbackQueryConvert.java index f942fc6..e1bc51f 100644 --- a/telegram-context/telegram-context-main/src/main/java/dev/struchkov/godfather/telegram/main/context/convert/CallbackQueryConvert.java +++ b/telegram-context/telegram-context-main/src/main/java/dev/struchkov/godfather/telegram/main/context/convert/CallbackQueryConvert.java @@ -3,6 +3,7 @@ package dev.struchkov.godfather.telegram.main.context.convert; import dev.struchkov.godfather.main.domain.content.Mail; import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment; import org.telegram.telegrambots.meta.api.objects.CallbackQuery; +import org.telegram.telegrambots.meta.api.objects.Message; import org.telegram.telegrambots.meta.api.objects.User; import java.time.LocalDateTime; @@ -21,7 +22,7 @@ public class CallbackQueryConvert { mail.setId(callbackQuery.getMessage().getMessageId().toString()); mail.setCreateDate(LocalDateTime.now()); mail.setText(callbackData); - mail.addAttachment(convertToButtonClick(callbackData, callbackQuery.getMessage().getMessageId())); + mail.addAttachment(convertToButtonClick(callbackData, callbackQuery.getMessage())); final Long chatId = callbackQuery.getFrom().getId(); mail.setFromPersonId(chatId.toString()); @@ -32,10 +33,10 @@ public class CallbackQueryConvert { return mail; } - private static ButtonClickAttachment convertToButtonClick(String callbackData, Integer messageId) { + private static ButtonClickAttachment convertToButtonClick(String callbackData, Message message) { final ButtonClickAttachment buttonClickAttachment = new ButtonClickAttachment(); buttonClickAttachment.setRawCallBackData(callbackData); - buttonClickAttachment.setMessageId(messageId.toString()); + buttonClickAttachment.setMessage(MessageMailConvert.apply(message)); if (callbackData.charAt(0) == '[' && callbackData.charAt(callbackData.length() - 1) == ']') { final String[] args = callbackData.substring(1, callbackData.length() - 1).split(";"); for (String arg : args) { diff --git a/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java index a8e904f..9c2cc00 100644 --- a/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java +++ b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java @@ -2,6 +2,7 @@ package dev.struchkov.godfather.telegram.domain.attachment; import com.fasterxml.jackson.annotation.JsonIgnore; import dev.struchkov.godfather.main.domain.content.Attachment; +import dev.struchkov.godfather.main.domain.content.Mail; import lombok.Getter; import lombok.Setter; @@ -17,11 +18,8 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull; @Setter public class ButtonClickAttachment extends Attachment { - /** - * Идентификатор сообщения, под которым пользователь нажал кнопку. - */ - private String messageId; private String rawCallBackData; + private Mail message; private Map args = new HashMap<>();