Вернул обработка вебхуков
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
36a5d1b478
commit
455a8e1316
@ -37,25 +37,16 @@ public class WebhookController {
|
|||||||
@Path("{webhookPath}")
|
@Path("{webhookPath}")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Produces(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) {
|
public Uni<Response> updateReceived(@PathParam("webhookPath") String botPath, @HeaderParam("X-Telegram-Bot-Api-Secret-Token") String secretTokenFromTelegram, Update update) {
|
||||||
Uni.createFrom().voidItem()
|
return Uni.createFrom().voidItem()
|
||||||
.invoke(() -> {
|
.invoke(() -> {
|
||||||
log.debug("Получено 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));
|
||||||
})
|
})
|
||||||
.call(
|
.call(() -> eventDistributor.processing(update))
|
||||||
() -> eventDistributor.processing(update)
|
.invoke(() -> log.debug("Дали отмашку, что все збс"))
|
||||||
.onFailure().recoverWithNull()
|
.map(ignored -> Response.ok().build());
|
||||||
)
|
|
||||||
.invoke(() -> log.debug("Webhook событие успешно обработано"))
|
|
||||||
.subscribe().with(
|
|
||||||
item -> {
|
|
||||||
},
|
|
||||||
failure -> log.error("Произошла ошибка: " + failure)
|
|
||||||
);
|
|
||||||
log.debug("Дали отмашку telegram, что webhook событие получено");
|
|
||||||
return Response.ok().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
|
Loading…
Reference in New Issue
Block a user