diff --git a/cmd/server/main.go b/cmd/server/main.go index a91aba6..408a7cb 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -10,6 +10,7 @@ import ( echologrus "github.com/davrux/echo-logrus/v4" "github.com/getsentry/sentry-go" + sentryecho "github.com/getsentry/sentry-go/echo" "github.com/labstack/echo/v4" "github.com/sirupsen/logrus" ddEcho "gopkg.in/DataDog/dd-trace-go.v1/contrib/labstack/echo.v4" @@ -24,16 +25,21 @@ func main() { logrus.Fatalf("Failed to initialize service: %v", err) } + e := echo.New() + e.HideBanner = true + echologrus.Logger = svc.Logger + e.Use(echologrus.Middleware()) + if svc.Cfg.SentryDSN != "" { if err = sentry.Init(sentry.ClientOptions{ Dsn: svc.Cfg.SentryDSN, }); err != nil { - logrus.Error(err) + svc.Logger.WithError(err).Error("Failed to init Sentry") } + defer sentry.Flush(2 * time.Second) + e.Use(sentryecho.New(sentryecho.Options{})) } - echologrus.Logger = svc.Logger - e := echo.New() if svc.Cfg.DatadogAgentUrl != "" { tracer.Start(tracer.WithService("http-nostr")) defer tracer.Stop() @@ -47,7 +53,6 @@ func main() { e.POST("/publish", svc.PublishHandler) e.POST("/subscriptions", svc.SubscriptionHandler) e.DELETE("/subscriptions/:id", svc.StopSubscriptionHandler) - e.Use(echologrus.Middleware()) //start Echo server go func() { diff --git a/internal/nostr/nostr.go b/internal/nostr/nostr.go index ee9f87a..87903bd 100644 --- a/internal/nostr/nostr.go +++ b/internal/nostr/nostr.go @@ -803,10 +803,10 @@ func (svc *Service) handleResponseEvent(event *nostr.Event, subscription *Subscr "client_pubkey": clientPubkey, "relay_url": subscription.RelayUrl, }).Info("Received response event") - if (subscription.RequestEvent != nil) { - subscription.RequestEvent.ResponseReceivedAt = time.Now() - svc.db.Save(&subscription.RequestEvent) - } + + subscription.RequestEvent.ResponseReceivedAt = time.Now() + svc.db.Save(&subscription.RequestEvent) + responseEvent := ResponseEvent{ NostrId: event.ID, Content: event.Content,