Add thread_id to filter

This commit is contained in:
Erik Johnston 2018-11-13 10:34:38 +00:00
parent 78fec6b3c9
commit c67953748d
3 changed files with 24 additions and 2 deletions

View file

@ -120,6 +120,9 @@ ROOM_EVENT_FILTER_SCHEMA = {
"include_redundant_members": { "include_redundant_members": {
"type": "boolean" "type": "boolean"
}, },
"thread_id": {
"type": "number",
}
} }
} }
@ -331,6 +334,8 @@ class Filter(object):
self.contains_url = self.filter_json.get("contains_url", None) 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): def filters_all_types(self):
return "*" in self.not_types return "*" in self.not_types

View file

@ -471,6 +471,11 @@ class RoomMessageListRestServlet(ClientV1RestServlet):
event_filter = Filter(json.loads(filter_json)) event_filter = Filter(json.loads(filter_json))
else: else:
event_filter = None 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( msgs = yield self.pagination_handler.get_messages(
room_id=room_id, room_id=room_id,
requester=requester, requester=requester,

View file

@ -149,7 +149,13 @@ def filter_to_clause(event_filter):
clauses.append("contains_url = ?") clauses.append("contains_url = ?")
args.append(event_filter.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): class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
@ -741,6 +747,11 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
filter_clause, filter_args = filter_to_clause(event_filter) 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: if filter_clause:
bounds += " AND " + filter_clause bounds += " AND " + filter_clause
args.extend(filter_args) args.extend(filter_args)
@ -808,7 +819,8 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
rows, token = yield self.runInteraction( rows, token = yield self.runInteraction(
"paginate_room_events", self._paginate_room_events_txn, "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( events = yield self._get_events(