refactor: code clean-up

This commit is contained in:
Vlad Stan 2023-02-02 10:26:25 +02:00
parent d4bfb0a815
commit 855ec09df3
2 changed files with 5 additions and 11 deletions

View file

@ -20,6 +20,11 @@ class NostrRelay(BaseModel):
def from_row(cls, row: Row) -> "NostrRelay":
return cls(**dict(row))
class NostrEventType(str, Enum):
EVENT = "EVENT"
REQ = "REQ"
CLOSE = "CLOSE"
class NostrEvent(BaseModel):
id: str
@ -109,16 +114,9 @@ class NostrFilter(BaseModel):
if len(filter_tags) == 0:
return True
#filter has tag
event_tag_values = [t[1] for t in event_tags if t[0] == tag_name]
common_tags = [event_tag for event_tag in event_tag_values if event_tag in filter_tags]
if len(common_tags) == 0:
return False
return True
class NostrEventType(str, Enum):
EVENT = "EVENT"
REQ = "REQ"
CLOSE = "CLOSE"

View file

@ -141,10 +141,6 @@ async def filter_by_tag_e_p_and_author(all_events: List[NostrEvent], author, eve
assert filtered_events[0].id == reply_event_id, f"Failed to filter the right event by 'author' and tags 'e' & 'p'"
def get_fixtures(file):
"""
Read the content of the JSON file.