Добавил преобразование ссылок во вложения
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Struchkov Mark 2023-01-27 10:59:19 +03:00
parent 790264ee96
commit 901a1cdc05
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6
2 changed files with 10 additions and 1 deletions

View File

@ -129,7 +129,12 @@ public final class MessageMailConvert {
private static Optional<Attachment> convertEntity(Message message, MessageEntity entity) {
switch (entity.getType()) {
case "text_link" -> {
return Optional.of(new LinkAttachment(entity.getUrl()));
return Optional.of(entity.getUrl())
.map(LinkAttachment::new);
}
case "url" -> {
return Optional.of(entity.getText())
.map(LinkAttachment::new);
}
case "bot_command" -> {
final String commandValue = entity.getText();

View File

@ -31,4 +31,8 @@ public class TriggerChecks {
return mail -> Attachments.findFirstButtonClick(mail.getAttachments()).isPresent();
}
public static Predicate<Mail> isLinks() {
return mail -> Attachments.findFirstLink(mail.getAttachments()).isPresent();
}
}