From f2a74857b7a07cfb33e012067df226fd406e29ad Mon Sep 17 00:00:00 2001 From: Neur0toxine Date: Fri, 29 Dec 2023 11:19:45 +0300 Subject: [PATCH] fix tg example --- examples/telegram/register.go | 2 +- examples/telegram/server.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/telegram/register.go b/examples/telegram/register.go index 2b27ecc..246a70e 100644 --- a/examples/telegram/register.go +++ b/examples/telegram/register.go @@ -18,7 +18,7 @@ func RegisterSystem() { AccountURL: AppConfig.BaseURL, Integrations: &retailcrm.Integrations{ MgTransport: &retailcrm.MgTransport{ - WebhookURL: AppConfig.BaseURL + "/api/v1/webhook", + WebhookURL: AppConfig.BaseURL + "/api/v1/mg", }, }, }) diff --git a/examples/telegram/server.go b/examples/telegram/server.go index 4017fda..2cab55c 100644 --- a/examples/telegram/server.go +++ b/examples/telegram/server.go @@ -39,10 +39,11 @@ func Listen() { signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) <-quit - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + log.Println("shutting down, please wait...") + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) defer cancel() if err := srv.Shutdown(ctx); err != nil { - log.Fatal("shutting down:", err) + log.Fatal("shutdown error:", err) } select { case <-ctx.Done(): @@ -65,7 +66,7 @@ func MGWebhookHandler(c *gin.Context) { } whMsg := wh.MessageWebhookData() - if strings.HasPrefix(whMsg.ExternalChatID, ChatIDPrefix) { + if !strings.HasPrefix(whMsg.ExternalChatID, ChatIDPrefix) { c.AbortWithStatusJSON(http.StatusUnprocessableEntity, v1.NewTransportErrorResponse(v1.MessageErrorGeneral, "unexpected chat ID")) return