From 36a5d1b4782e753f82bb1ea74d8397f1db7d2c9d Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Mon, 17 Apr 2023 01:04:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BF=D0=BE=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20WebhookController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../telegram/webhook/WebhookController.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 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 a62869f..1c8c498 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,19 +37,25 @@ public class WebhookController { @Path("{webhookPath}") @Consumes(MediaType.APPLICATION_JSON) @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() + public Response updateReceived(@PathParam("webhookPath") String botPath, @HeaderParam("X-Telegram-Bot-Api-Secret-Token") String secretTokenFromTelegram, Update update) { + Uni.createFrom().voidItem() .invoke(() -> { - log.trace("Получено webhook событие"); + log.debug("Получено webhook событие"); isTrue(pathKey.equals(botPath), accessException(ERROR_ACCESS)); isTrue(secretToken.equals(secretTokenFromTelegram), accessException(ERROR_ACCESS)); }) - .onItem().ignore().andSwitchTo( + .call( () -> eventDistributor.processing(update) .onFailure().recoverWithNull() ) - .invoke(() -> log.trace("Webhook событие успешно обработано")) - .replaceWith(Response.ok().build()); + .invoke(() -> log.debug("Webhook событие успешно обработано")) + .subscribe().with( + item -> { + }, + failure -> log.error("Произошла ошибка: " + failure) + ); + log.debug("Дали отмашку telegram, что webhook событие получено"); + return Response.ok().build(); } @GET