test: add tests for filtering
This commit is contained in:
parent
80ae3db4c1
commit
d4bfb0a815
2 changed files with 86 additions and 51 deletions
11
models.py
11
models.py
|
|
@ -105,11 +105,14 @@ class NostrFilter(BaseModel):
|
|||
return True
|
||||
|
||||
def tag_in_list(self, event_tags, tag_name) -> bool:
|
||||
tag_values = [t[1] for t in event_tags if t[0] == tag_name]
|
||||
if len(tag_values) == 0:
|
||||
return True
|
||||
filter_tags = dict(self).get(tag_name, [])
|
||||
common_tags = [t for t in tag_values if t in filter_tags]
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue