diff --git a/telegram-consumer/telegram-consumer-main/src/main/java/dev/struchkov/godfather/telegram/main/consumer/CallbackQueryConvert.java b/telegram-consumer/telegram-consumer-main/src/main/java/dev/struchkov/godfather/telegram/main/consumer/CallbackQueryConvert.java index 302ed79..1884a02 100644 --- a/telegram-consumer/telegram-consumer-main/src/main/java/dev/struchkov/godfather/telegram/main/consumer/CallbackQueryConvert.java +++ b/telegram-consumer/telegram-consumer-main/src/main/java/dev/struchkov/godfather/telegram/main/consumer/CallbackQueryConvert.java @@ -20,7 +20,7 @@ public class CallbackQueryConvert { final Mail mail = new Mail(); mail.setCreateDate(LocalDateTime.now()); mail.setText(callbackData); - mail.addAttachment(convertToButtonClick(callbackData)); + mail.addAttachment(convertToButtonClick(callbackData, callbackQuery.getMessage().getMessageId())); final Long chatId = callbackQuery.getMessage().getChatId(); mail.setPersonId(chatId != null ? chatId.toString() : null); @@ -31,9 +31,10 @@ public class CallbackQueryConvert { return mail; } - private static ButtonClickAttachment convertToButtonClick(String callbackData) { + private static ButtonClickAttachment convertToButtonClick(String callbackData, Integer messageId) { final ButtonClickAttachment buttonClickAttachment = new ButtonClickAttachment(); buttonClickAttachment.setRawCallBackData(callbackData); + buttonClickAttachment.setMessageId(messageId); 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/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java b/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java index c7d3eac..bf8f6a7 100644 --- a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java +++ b/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java @@ -12,6 +12,10 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull; public class ButtonClickAttachment extends Attachment { + /** + * Идентификатор сообщения, под которым пользователь нажал кнопку. + */ + private Integer messageId; private String rawCallBackData; private final Map args = new HashMap<>(); @@ -42,6 +46,18 @@ public class ButtonClickAttachment extends Attachment { return args.values(); } + public Integer getMessageId() { + return messageId; + } + + public void setMessageId(Integer messageId) { + this.messageId = messageId; + } + + public Map getArgs() { + return args; + } + @Override public String getType() { return TelegramAttachmentType.BUTTON_CLICK.name();