Merge pull request #517 from matrix-org/erikj/push_only_room
Only fetch events for rooms and receipts
This commit is contained in:
commit
297eded261
|
@ -113,10 +113,10 @@ class EventStreamHandler(BaseHandler):
|
||||||
@log_function
|
@log_function
|
||||||
def get_stream(self, auth_user_id, pagin_config, timeout=0,
|
def get_stream(self, auth_user_id, pagin_config, timeout=0,
|
||||||
as_client_event=True, affect_presence=True,
|
as_client_event=True, affect_presence=True,
|
||||||
only_room_events=False, room_id=None, is_guest=False):
|
only_keys=None, room_id=None, is_guest=False):
|
||||||
"""Fetches the events stream for a given user.
|
"""Fetches the events stream for a given user.
|
||||||
|
|
||||||
If `only_room_events` is `True` only room events will be returned.
|
If `only_keys` is not None, events from keys will be sent down.
|
||||||
"""
|
"""
|
||||||
auth_user = UserID.from_string(auth_user_id)
|
auth_user = UserID.from_string(auth_user_id)
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ class EventStreamHandler(BaseHandler):
|
||||||
|
|
||||||
events, tokens = yield self.notifier.get_events_for(
|
events, tokens = yield self.notifier.get_events_for(
|
||||||
auth_user, pagin_config, timeout,
|
auth_user, pagin_config, timeout,
|
||||||
only_room_events=only_room_events,
|
only_keys=only_keys,
|
||||||
is_guest=is_guest, explicit_room_id=room_id
|
is_guest=is_guest, explicit_room_id=room_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -331,13 +331,13 @@ class Notifier(object):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_events_for(self, user, pagination_config, timeout,
|
def get_events_for(self, user, pagination_config, timeout,
|
||||||
only_room_events=False,
|
only_keys=None,
|
||||||
is_guest=False, explicit_room_id=None):
|
is_guest=False, explicit_room_id=None):
|
||||||
""" For the given user and rooms, return any new events for them. If
|
""" For the given user and rooms, return any new events for them. If
|
||||||
there are no new events wait for up to `timeout` milliseconds for any
|
there are no new events wait for up to `timeout` milliseconds for any
|
||||||
new events to happen before returning.
|
new events to happen before returning.
|
||||||
|
|
||||||
If `only_room_events` is `True` only room events will be returned.
|
If `only_keys` is not None, events from keys will be sent down.
|
||||||
|
|
||||||
If explicit_room_id is not set, the user's joined rooms will be polled
|
If explicit_room_id is not set, the user's joined rooms will be polled
|
||||||
for events.
|
for events.
|
||||||
|
@ -367,7 +367,7 @@ class Notifier(object):
|
||||||
after_id = getattr(after_token, keyname)
|
after_id = getattr(after_token, keyname)
|
||||||
if before_id == after_id:
|
if before_id == after_id:
|
||||||
continue
|
continue
|
||||||
if only_room_events and name != "room":
|
if only_keys and name not in only_keys:
|
||||||
continue
|
continue
|
||||||
new_events, new_key = yield source.get_new_events(
|
new_events, new_key = yield source.get_new_events(
|
||||||
user=user,
|
user=user,
|
||||||
|
|
|
@ -126,7 +126,8 @@ class Pusher(object):
|
||||||
config = PaginationConfig(from_token=from_tok, limit='1')
|
config = PaginationConfig(from_token=from_tok, limit='1')
|
||||||
timeout = (300 + random.randint(-60, 60)) * 1000
|
timeout = (300 + random.randint(-60, 60)) * 1000
|
||||||
chunk = yield self.evStreamHandler.get_stream(
|
chunk = yield self.evStreamHandler.get_stream(
|
||||||
self.user_id, config, timeout=timeout, affect_presence=False
|
self.user_id, config, timeout=timeout, affect_presence=False,
|
||||||
|
only_keys=("room", "receipt",),
|
||||||
)
|
)
|
||||||
|
|
||||||
# limiting to 1 may get 1 event plus 1 presence event, so
|
# limiting to 1 may get 1 event plus 1 presence event, so
|
||||||
|
|
Loading…
Reference in New Issue