mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-19 01:21:09 +03:00
Add thread_id to filter
This commit is contained in:
parent
78fec6b3c9
commit
c67953748d
3 changed files with 24 additions and 2 deletions
|
@ -120,6 +120,9 @@ ROOM_EVENT_FILTER_SCHEMA = {
|
|||
"include_redundant_members": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"thread_id": {
|
||||
"type": "number",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,6 +334,8 @@ class Filter(object):
|
|||
|
||||
self.contains_url = self.filter_json.get("contains_url", None)
|
||||
|
||||
self.thread_id = self.filter_json.get("thread_id", None)
|
||||
|
||||
def filters_all_types(self):
|
||||
return "*" in self.not_types
|
||||
|
||||
|
|
|
@ -471,6 +471,11 @@ class RoomMessageListRestServlet(ClientV1RestServlet):
|
|||
event_filter = Filter(json.loads(filter_json))
|
||||
else:
|
||||
event_filter = None
|
||||
|
||||
logger.info("filter_bytes: %s", filter_bytes)
|
||||
logger.info("Event filter: %s", event_filter)
|
||||
if event_filter:
|
||||
logger.info("Event filter: %s", event_filter.thread_id)
|
||||
msgs = yield self.pagination_handler.get_messages(
|
||||
room_id=room_id,
|
||||
requester=requester,
|
||||
|
|
|
@ -149,7 +149,13 @@ def filter_to_clause(event_filter):
|
|||
clauses.append("contains_url = ?")
|
||||
args.append(event_filter.contains_url)
|
||||
|
||||
return " AND ".join(clauses), args
|
||||
if event_filter.thread_id is not None:
|
||||
clauses.append("thread_id = ?")
|
||||
args.append(event_filter.thread_id)
|
||||
|
||||
filter = " AND ".join(clauses), args
|
||||
|
||||
return filter
|
||||
|
||||
|
||||
class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
|
||||
|
@ -741,6 +747,11 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
|
|||
|
||||
filter_clause, filter_args = filter_to_clause(event_filter)
|
||||
|
||||
logger.info("event_filter: %s", event_filter)
|
||||
if event_filter is not None:
|
||||
logger.info("event_filter: %s", event_filter.thread_id)
|
||||
logger.info("Paginating with filter: %s", filter_clause)
|
||||
|
||||
if filter_clause:
|
||||
bounds += " AND " + filter_clause
|
||||
args.extend(filter_args)
|
||||
|
@ -808,7 +819,8 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
|
|||
|
||||
rows, token = yield self.runInteraction(
|
||||
"paginate_room_events", self._paginate_room_events_txn,
|
||||
room_id, from_key, to_key, direction, limit, event_filter,
|
||||
room_id, from_key, to_key, direction, limit,
|
||||
event_filter=event_filter,
|
||||
)
|
||||
|
||||
events = yield self._get_events(
|
||||
|
|
Loading…
Reference in a new issue