From 455a8e131646f7deafc9273b89820ebfa25f6a8e Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Wed, 19 Apr 2023 10:22:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B5=D1=80=D0=BD=D1=83=D0=BB=20=D0=BE?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B0=20=D0=B2=D0=B5?= =?UTF-8?q?=D0=B1=D1=85=D1=83=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../telegram/webhook/WebhookController.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) 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 1c8c498..d6590a3 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 @@ -37,25 +37,16 @@ public class WebhookController { @Path("{webhookPath}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response updateReceived(@PathParam("webhookPath") String botPath, @HeaderParam("X-Telegram-Bot-Api-Secret-Token") String secretTokenFromTelegram, Update update) { - Uni.createFrom().voidItem() + public Uni updateReceived(@PathParam("webhookPath") String botPath, @HeaderParam("X-Telegram-Bot-Api-Secret-Token") String secretTokenFromTelegram, Update update) { + return Uni.createFrom().voidItem() .invoke(() -> { log.debug("Получено webhook событие"); isTrue(pathKey.equals(botPath), accessException(ERROR_ACCESS)); isTrue(secretToken.equals(secretTokenFromTelegram), accessException(ERROR_ACCESS)); }) - .call( - () -> eventDistributor.processing(update) - .onFailure().recoverWithNull() - ) - .invoke(() -> log.debug("Webhook событие успешно обработано")) - .subscribe().with( - item -> { - }, - failure -> log.error("Произошла ошибка: " + failure) - ); - log.debug("Дали отмашку telegram, что webhook событие получено"); - return Response.ok().build(); + .call(() -> eventDistributor.processing(update)) + .invoke(() -> log.debug("Дали отмашку, что все збс")) + .map(ignored -> Response.ok().build()); } @GET