Поправил поведение WebhookController
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Struchkov Mark 2023-04-17 01:04:14 +03:00
parent a18dceb617
commit 36a5d1b478
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6

View File

@ -37,19 +37,25 @@ public class WebhookController {
@Path("{webhookPath}") @Path("{webhookPath}")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public Uni<Response> updateReceived(@PathParam("webhookPath") String botPath, @HeaderParam("X-Telegram-Bot-Api-Secret-Token") String secretTokenFromTelegram, Update update) { public Response updateReceived(@PathParam("webhookPath") String botPath, @HeaderParam("X-Telegram-Bot-Api-Secret-Token") String secretTokenFromTelegram, Update update) {
return Uni.createFrom().voidItem() Uni.createFrom().voidItem()
.invoke(() -> { .invoke(() -> {
log.trace("Получено webhook событие"); log.debug("Получено webhook событие");
isTrue(pathKey.equals(botPath), accessException(ERROR_ACCESS)); isTrue(pathKey.equals(botPath), accessException(ERROR_ACCESS));
isTrue(secretToken.equals(secretTokenFromTelegram), accessException(ERROR_ACCESS)); isTrue(secretToken.equals(secretTokenFromTelegram), accessException(ERROR_ACCESS));
}) })
.onItem().ignore().andSwitchTo( .call(
() -> eventDistributor.processing(update) () -> eventDistributor.processing(update)
.onFailure().recoverWithNull() .onFailure().recoverWithNull()
) )
.invoke(() -> log.trace("Webhook событие успешно обработано")) .invoke(() -> log.debug("Webhook событие успешно обработано"))
.replaceWith(Response.ok().build()); .subscribe().with(
item -> {
},
failure -> log.error("Произошла ошибка: " + failure)
);
log.debug("Дали отмашку telegram, что webhook событие получено");
return Response.ok().build();
} }
@GET @GET