Compare commits
No commits in common. "main" and "v0.0.1" have entirely different histories.
2 changed files with 4 additions and 16 deletions
|
|
@ -77,10 +77,6 @@ class NostrClientConnection:
|
||||||
resp = event.serialize_response(nostr_filter.subscription_id)
|
resp = event.serialize_response(nostr_filter.subscription_id)
|
||||||
await self._send_msg(resp)
|
await self._send_msg(resp)
|
||||||
return True
|
return True
|
||||||
else:
|
|
||||||
logger.info(
|
|
||||||
f"[NOSTRRELAY CLIENT] ❌ Filter didn't match for event {event.id}"
|
|
||||||
)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _is_direct_message_for_other(self, event: NostrEvent) -> bool:
|
def _is_direct_message_for_other(self, event: NostrEvent) -> bool:
|
||||||
|
|
@ -102,10 +98,6 @@ class NostrClientConnection:
|
||||||
async def _broadcast_event(self, e: NostrEvent):
|
async def _broadcast_event(self, e: NostrEvent):
|
||||||
if self.broadcast_event:
|
if self.broadcast_event:
|
||||||
await self.broadcast_event(self, e)
|
await self.broadcast_event(self, e)
|
||||||
else:
|
|
||||||
logger.warning(
|
|
||||||
f"[NOSTRRELAY CLIENT] ❌ No broadcast_event callback available for event {e.id}"
|
|
||||||
)
|
|
||||||
|
|
||||||
async def _handle_message(self, data: list) -> list:
|
async def _handle_message(self, data: list) -> list:
|
||||||
if len(data) < 2:
|
if len(data) < 2:
|
||||||
|
|
@ -121,8 +113,6 @@ class NostrClientConnection:
|
||||||
}
|
}
|
||||||
|
|
||||||
event = NostrEvent(**event_dict)
|
event = NostrEvent(**event_dict)
|
||||||
# Set the size field from the size_bytes property
|
|
||||||
event.size = event.size_bytes
|
|
||||||
await self._handle_event(event)
|
await self._handle_event(event)
|
||||||
return []
|
return []
|
||||||
if message_type == NostrEventType.REQ:
|
if message_type == NostrEventType.REQ:
|
||||||
|
|
@ -130,8 +120,6 @@ class NostrClientConnection:
|
||||||
return []
|
return []
|
||||||
subscription_id = data[1]
|
subscription_id = data[1]
|
||||||
# Handle multiple filters in REQ message
|
# Handle multiple filters in REQ message
|
||||||
# First remove existing filters for this subscription_id
|
|
||||||
self._remove_filter(subscription_id)
|
|
||||||
responses = []
|
responses = []
|
||||||
for filter_data in data[2:]:
|
for filter_data in data[2:]:
|
||||||
response = await self._handle_request(
|
response = await self._handle_request(
|
||||||
|
|
@ -305,7 +293,8 @@ class NostrClientConnection:
|
||||||
return [["NOTICE", f"This is a paid relay: '{self.relay_id}'"]]
|
return [["NOTICE", f"This is a paid relay: '{self.relay_id}'"]]
|
||||||
|
|
||||||
nostr_filter.subscription_id = subscription_id
|
nostr_filter.subscription_id = subscription_id
|
||||||
if not self._can_add_filter():
|
self._remove_filter(subscription_id)
|
||||||
|
if self._can_add_filter():
|
||||||
max_filters = self.config.max_client_filters
|
max_filters = self.config.max_client_filters
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
|
|
@ -336,8 +325,8 @@ class NostrClientConnection:
|
||||||
|
|
||||||
def _can_add_filter(self) -> bool:
|
def _can_add_filter(self) -> bool:
|
||||||
return (
|
return (
|
||||||
self.config.max_client_filters == 0
|
self.config.max_client_filters != 0
|
||||||
or len(self.filters) < self.config.max_client_filters
|
and len(self.filters) >= self.config.max_client_filters
|
||||||
)
|
)
|
||||||
|
|
||||||
def _auth_challenge_expired(self):
|
def _auth_challenge_expired(self):
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ class NostrEvent(BaseModel):
|
||||||
tags: list[list[str]] = Field(default=[], no_database=True)
|
tags: list[list[str]] = Field(default=[], no_database=True)
|
||||||
content: str = ""
|
content: str = ""
|
||||||
sig: str
|
sig: str
|
||||||
size: int = 0
|
|
||||||
|
|
||||||
def nostr_dict(self) -> dict:
|
def nostr_dict(self) -> dict:
|
||||||
_nostr_dict = dict(self)
|
_nostr_dict = dict(self)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue