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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
This commit is contained in:
Padreug 2026-09-13 17:55:13 +02:00
commit 2f965e0023

View file

@ -26,10 +26,17 @@ class NostrEvent(BaseModel):
size: int = 0 size: int = 0
def nostr_dict(self) -> dict: def nostr_dict(self) -> dict:
_nostr_dict = dict(self) # Only the NIP-01 fields go on the wire; storage columns such as
_nostr_dict.pop("relay_id") # relay_id, publisher and size must not leak into EVENT responses.
_nostr_dict.pop("publisher") return {
return _nostr_dict "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: def serialize(self) -> list:
return [0, self.pubkey, self.created_at, self.kind, self.tags, self.content] return [0, self.pubkey, self.created_at, self.kind, self.tags, self.content]