aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-12-04 03:48:10 +0300
committerGravatar Vitaly Takmazov2023-12-04 03:48:10 +0300
commitfa89377ea880c2fc6f382ba988675fe159ad85fc (patch)
tree955cdeb6340c089278e510c021b6bba4c76456b1 /src/main/java/com/juick
parenta0d0c005568bba9db384f4fc5d13f60b27979cdf (diff)
Use telegram message caption when trying to edit message with image
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/TelegramBotManager.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main/java/com/juick/TelegramBotManager.java b/src/main/java/com/juick/TelegramBotManager.java
index 3335b61a..dec0bd1d 100644
--- a/src/main/java/com/juick/TelegramBotManager.java
+++ b/src/main/java/com/juick/TelegramBotManager.java
@@ -60,6 +60,7 @@ import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.*;
+import java.util.stream.Stream;
import static com.juick.util.formatters.PlainTextFormatter.formatPost;
import static com.juick.util.formatters.PlainTextFormatter.formatUrl;
@@ -147,7 +148,8 @@ public class TelegramBotManager implements NotificationListener {
com.juick.model.Message originalMessage = rid == 0 ? messagesService.getMessage(mid).orElseThrow(IllegalStateException::new)
: messagesService.getReply(mid, rid);
User author = originalMessage.getUser();
- String newMessageText = StringUtils.defaultString(message.text());
+ String newMessageText = Stream.of(message.text(), message.caption()).filter(Objects::nonNull)
+ .findFirst().orElse(StringUtils.EMPTY);
if (user_from.equals(author) && canUpdateMessage(originalMessage, newMessageText)) {
if (messagesService.updateMessage(mid, rid, newMessageText, false)) {
telegramNotify(message.chat().id(), "Message updated", new com.juick.model.Message());