From 2f965e0023cf100b7820f0717207ca7f4969c06b Mon Sep 17 00:00:00 2001 From: Padreug Date: Sun, 13 Sep 2026 17:55:13 +0200 Subject: [PATCH] fix: send only NIP-01 fields in EVENT responses nostr_dict() returned every model field except relay_id and publisher, so the size column added for storage accounting leaked into every EVENT sent to clients. Emit the seven NIP-01 fields explicitly instead. Caught by the client-flow test ported from upstream. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt --- relay/event.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/relay/event.py b/relay/event.py index dc23234..ed9054f 100644 --- a/relay/event.py +++ b/relay/event.py @@ -26,10 +26,17 @@ class NostrEvent(BaseModel): size: int = 0 def nostr_dict(self) -> dict: - _nostr_dict = dict(self) - _nostr_dict.pop("relay_id") - _nostr_dict.pop("publisher") - return _nostr_dict + # Only the NIP-01 fields go on the wire; storage columns such as + # relay_id, publisher and size must not leak into EVENT responses. + return { + "id": self.id, + "pubkey": self.pubkey, + "created_at": self.created_at, + "kind": self.kind, + "tags": self.tags, + "content": self.content, + "sig": self.sig, + } def serialize(self) -> list: return [0, self.pubkey, self.created_at, self.kind, self.tags, self.content]