From 476a97001cd84f6654ee1f7b48b29a40e376d773 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sun, 2 Apr 2023 14:39:12 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20=D0=BB?= =?UTF-8?q?=D0=B8=D1=88=D0=BD=D0=B8=D0=B9=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4?= =?UTF-8?q?=20=D0=B2=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../godfather/telegram/quarkus/sender/TelegramSender.java | 6 +----- .../godfather/telegram/simple/sender/TelegramSender.java | 5 ----- .../godfather/telegram/webhook/WebhookController.java | 7 +++++-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/TelegramSender.java b/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/TelegramSender.java index 315134a..eeda8b6 100644 --- a/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/TelegramSender.java +++ b/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/TelegramSender.java @@ -87,11 +87,6 @@ public class TelegramSender implements TelegramSending { return Uni.createFrom().voidItem(); } - @Override - public Uni replaceMessage(@NotNull String personId, @NotNull String messageId, @NotNull BoxAnswer newAnswer) { - return replace(personId, messageId, newAnswer, true); - } - @Override public Uni sendNotSave(@NotNull BoxAnswer boxAnswer) { return sendBoxAnswer(boxAnswer, false); @@ -222,6 +217,7 @@ public class TelegramSender implements TelegramSending { final Message lastMessage = answerMessages.get(answerMessages.size() - 1); final SentBox sentBox = new SentBox(); + sentBox.setPersonId(telegramId); sentBox.setMessageId(lastMessage.getMessageId().toString()); sentBox.setOriginalAnswer(boxAnswer); sentBox.setSentAnswer(boxAnswer); diff --git a/telegram-sender/telegram-sender-simple/src/main/java/dev/struchkov/godfather/telegram/simple/sender/TelegramSender.java b/telegram-sender/telegram-sender-simple/src/main/java/dev/struchkov/godfather/telegram/simple/sender/TelegramSender.java index 6714a85..2a10828 100644 --- a/telegram-sender/telegram-sender-simple/src/main/java/dev/struchkov/godfather/telegram/simple/sender/TelegramSender.java +++ b/telegram-sender/telegram-sender-simple/src/main/java/dev/struchkov/godfather/telegram/simple/sender/TelegramSender.java @@ -85,11 +85,6 @@ public class TelegramSender implements TelegramSending { } } - @Override - public Optional replaceMessage(@NotNull String personId, @NotNull String messageId, @NotNull BoxAnswer newAnswer) { - return replace(personId, messageId, newAnswer, newAnswer, true); - } - @Override public Optional send(@NotNull BoxAnswer boxAnswer) { isNotNull(boxAnswer.getRecipientPersonId()); diff --git a/telegram-webhook/telegram-webhook-quarkus/src/main/java/dev/struchkov/godfather/telegram/webhook/WebhookController.java b/telegram-webhook/telegram-webhook-quarkus/src/main/java/dev/struchkov/godfather/telegram/webhook/WebhookController.java index f1d48fc..a62869f 100644 --- a/telegram-webhook/telegram-webhook-quarkus/src/main/java/dev/struchkov/godfather/telegram/webhook/WebhookController.java +++ b/telegram-webhook/telegram-webhook-quarkus/src/main/java/dev/struchkov/godfather/telegram/webhook/WebhookController.java @@ -39,12 +39,15 @@ public class WebhookController { @Produces(MediaType.APPLICATION_JSON) public Uni updateReceived(@PathParam("webhookPath") String botPath, @HeaderParam("X-Telegram-Bot-Api-Secret-Token") String secretTokenFromTelegram, Update update) { return Uni.createFrom().voidItem() - .invoke(() -> log.trace("Получено webhook событие")) .invoke(() -> { + log.trace("Получено webhook событие"); isTrue(pathKey.equals(botPath), accessException(ERROR_ACCESS)); isTrue(secretToken.equals(secretTokenFromTelegram), accessException(ERROR_ACCESS)); }) - .onItem().ignore().andSwitchTo(() -> eventDistributor.processing(update)) + .onItem().ignore().andSwitchTo( + () -> eventDistributor.processing(update) + .onFailure().recoverWithNull() + ) .invoke(() -> log.trace("Webhook событие успешно обработано")) .replaceWith(Response.ok().build()); }