mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Add filtering.filter_events function, with stub passes_filter function.
This commit is contained in:
parent
3773759c0f
commit
2a4fda7b88
@ -34,6 +34,21 @@ class Filtering(object):
|
|||||||
# replace_user_filter at some point? There's no REST API specified for
|
# replace_user_filter at some point? There's no REST API specified for
|
||||||
# them however
|
# them however
|
||||||
|
|
||||||
|
def passes_filter(self, filter_json, event):
|
||||||
|
"""Check if the event passes through the filter.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
filter_json(dict): The filter specification
|
||||||
|
event(Event): The event to check
|
||||||
|
Returns:
|
||||||
|
True if the event passes through the filter.
|
||||||
|
"""
|
||||||
|
return True
|
||||||
|
|
||||||
|
def filter_events(self, events, user, filter_id):
|
||||||
|
filter_json = self.get_user_filter(user, filter_id)
|
||||||
|
return [e for e in events if self.passes_filter(filter_json, e)]
|
||||||
|
|
||||||
def _check_valid_filter(self, user_filter):
|
def _check_valid_filter(self, user_filter):
|
||||||
"""Check if the provided filter is valid.
|
"""Check if the provided filter is valid.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user