feat: finish NIP16
This commit is contained in:
parent
a1d7c474b0
commit
5c0209b6c0
3 changed files with 14 additions and 5 deletions
|
|
@ -210,9 +210,10 @@ class NostrClientConnection:
|
|||
try:
|
||||
if e.is_replaceable_event:
|
||||
await delete_events(
|
||||
self.relay_id, NostrFilter(kinds=[e.kind], authors=[e.pubkey])
|
||||
self.relay_id, NostrFilter(kinds=[e.kind], authors=[e.pubkey], until=e.created_at)
|
||||
)
|
||||
await create_event(self.relay_id, e, self.pubkey)
|
||||
if not e.is_ephemeral_event:
|
||||
await create_event(self.relay_id, e, self.pubkey)
|
||||
await self._broadcast_event(e)
|
||||
|
||||
if e.is_delete_event:
|
||||
|
|
@ -307,6 +308,9 @@ class NostrClientConnection:
|
|||
if not valid:
|
||||
return (valid, message)
|
||||
|
||||
if e.is_ephemeral_event:
|
||||
return True, ""
|
||||
|
||||
publisher_pubkey = self.pubkey if self.pubkey else e.pubkey
|
||||
valid, message = await self._validate_storage(publisher_pubkey, e.size_bytes)
|
||||
if not valid:
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ class NostrEvent(BaseModel):
|
|||
|
||||
@property
|
||||
def is_replaceable_event(self) -> bool:
|
||||
return self.kind in [0, 3, 41]
|
||||
return self.kind in [0, 3, 41] or (self.kind >= 10000 and self.kind < 20000)
|
||||
|
||||
@property
|
||||
def is_auth_response_event(self) -> bool:
|
||||
|
|
@ -181,9 +181,14 @@ class NostrEvent(BaseModel):
|
|||
def is_delete_event(self) -> bool:
|
||||
return self.kind == 5
|
||||
|
||||
@property
|
||||
def is_regular_event(self) -> bool:
|
||||
return self.kind >= 1000 and self.kind < 10000
|
||||
|
||||
@property
|
||||
def is_ephemeral_event(self) -> bool:
|
||||
return self.kind in [22242]
|
||||
return self.kind >= 20000 and self.kind < 30000
|
||||
|
||||
|
||||
def check_signature(self):
|
||||
event_id = self.event_id
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ async def test_valid_event_crud(valid_events: List[EventFixture]):
|
|||
|
||||
# insert all events in DB before doing an query
|
||||
for e in all_events:
|
||||
await create_event(RELAY_ID, e)
|
||||
await create_event(RELAY_ID, e, None)
|
||||
|
||||
for f in valid_events:
|
||||
await get_by_id(f.data, f.name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue