Добавил обработку подписи к изображениям
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
Struchkov Mark 2023-11-18 18:06:21 +03:00
parent 58fc497894
commit 78a072ed90
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6

View File

@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import static dev.struchkov.haiti.utils.Checker.checkNotBlank;
import static dev.struchkov.haiti.utils.Exceptions.utilityClass; import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
/** /**
@ -46,7 +47,7 @@ public final class MessageMailConvert {
final Long chatId = message.getChatId(); final Long chatId = message.getChatId();
mail.setId(message.getMessageId().toString()); mail.setId(message.getMessageId().toString());
mail.setFromPersonId(chatId != null ? chatId.toString() : null); 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())); mail.setCreateDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(message.getDate()), ZoneId.systemDefault()));
final Chat chat = message.getChat(); final Chat chat = message.getChat();
@ -71,6 +72,16 @@ public final class MessageMailConvert {
return mail; 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<Attachment> convertPhoto(List<PhotoSize> photoSizes) { private static Optional<Attachment> convertPhoto(List<PhotoSize> photoSizes) {
if (photoSizes != null && !photoSizes.isEmpty()) { if (photoSizes != null && !photoSizes.isEmpty()) {
final PictureGroupAttachment attachment = new PictureGroupAttachment(); final PictureGroupAttachment attachment = new PictureGroupAttachment();