From eb92c2aac5179d7dbecedf59e33ff3ddd6361773 Mon Sep 17 00:00:00 2001 From: kehiy Date: Sat, 14 Sep 2024 15:03:09 +0330 Subject: [PATCH] make check id more simple. --- handlers.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/handlers.go b/handlers.go index 1ffd500..d3016c8 100644 --- a/handlers.go +++ b/handlers.go @@ -3,7 +3,6 @@ package khatru import ( "context" "crypto/rand" - "crypto/sha256" "encoding/hex" "errors" "net/http" @@ -128,9 +127,7 @@ func (rl *Relay) HandleWebsocket(w http.ResponseWriter, r *http.Request) { switch env := envelope.(type) { case *nostr.EventEnvelope: // check id - hash := sha256.Sum256(env.Event.Serialize()) - id := hex.EncodeToString(hash[:]) - if id != env.Event.ID { + if env.Event.GetID() != env.Event.ID { ws.WriteJSON(nostr.OKEnvelope{EventID: env.Event.ID, OK: false, Reason: "invalid: id is computed incorrectly"}) return }