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:
parent
fd19acff97
commit
2f965e0023
1 changed files with 11 additions and 4 deletions
|
|
@ -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]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue