From 78a072ed9012d4ac020aab7aada28fe3e76e9b5d Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sat, 18 Nov 2023 18:06:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D1=83=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=BF=D0=B8=D1=81=D0=B8=20=D0=BA=20=D0=B8=D0=B7?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/context/convert/MessageMailConvert.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/telegram-context/telegram-context-main/src/main/java/dev/struchkov/godfather/telegram/main/context/convert/MessageMailConvert.java b/telegram-context/telegram-context-main/src/main/java/dev/struchkov/godfather/telegram/main/context/convert/MessageMailConvert.java index ac1bc66..0056800 100644 --- a/telegram-context/telegram-context-main/src/main/java/dev/struchkov/godfather/telegram/main/context/convert/MessageMailConvert.java +++ b/telegram-context/telegram-context-main/src/main/java/dev/struchkov/godfather/telegram/main/context/convert/MessageMailConvert.java @@ -27,6 +27,7 @@ import java.util.Collections; import java.util.List; import java.util.Optional; +import static dev.struchkov.haiti.utils.Checker.checkNotBlank; import static dev.struchkov.haiti.utils.Exceptions.utilityClass; /** @@ -46,7 +47,7 @@ public final class MessageMailConvert { final Long chatId = message.getChatId(); mail.setId(message.getMessageId().toString()); mail.setFromPersonId(chatId != null ? chatId.toString() : null); - mail.setText(message.getText()); + mail.setText(getText(message)); mail.setCreateDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(message.getDate()), ZoneId.systemDefault())); final Chat chat = message.getChat(); @@ -71,6 +72,16 @@ public final class MessageMailConvert { return mail; } + private static String getText(Message message) { + if (checkNotBlank(message.getText())) { + return message.getText(); + } + if (checkNotBlank(message.getCaption())) { + return message.getCaption(); + } + return null; + } + private static Optional convertPhoto(List photoSizes) { if (photoSizes != null && !photoSizes.isEmpty()) { final PictureGroupAttachment attachment = new PictureGroupAttachment();