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