-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
speed up /members and add at= and membership params #3568
Changes from 12 commits
7b7fd27
c341d81
f7bd5da
589e5aa
8e66dd1
a08b37b
7362e6c
cd28d2f
a17f0b6
9ba6ef2
c6117fa
8f1585d
f9c3c26
c2870ab
ffb7a4c
7d99b0e
cd27a77
4018a6d
d32e5f8
238f750
2a79e1a
48f3e43
08af91d
e952368
2d9c062
eebee08
859ad35
dd4498f
217d5dd
f5189b9
0d5770d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -329,14 +329,24 @@ def _check_in_room_or_world_readable(self, room_id, user_id): | |
) | ||
|
||
@defer.inlineCallbacks | ||
def get_state_events(self, user_id, room_id, is_guest=False): | ||
def get_state_events( | ||
self, user_id, room_id, types=None, filtered_types=None, | ||
at_event=None, is_guest=False | ||
): | ||
"""Retrieve all state events for a given room. If the user is | ||
joined to the room then return the current state. If the user has | ||
left the room return the state events from when they left. | ||
left the room return the state events from when they left. If an explicit | ||
'at' parameter is passed, return the state events as of that event. | ||
|
||
Args: | ||
user_id(str): The user requesting state events. | ||
room_id(str): The room ID to get all state events from. | ||
types(list[(Str, (Str|None))]): the (type, state_key)s to return | ||
results for. | ||
filtered_types(list[Str]): the list of types to apply the types filter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
to. | ||
at_event(str): the event_id we are requesting the state as of | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
is_guest(Boolean): whether this user is a guest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you've been writing too much javascript :)
|
||
Returns: | ||
A list of dicts representing state events. [{}, {}, {}] | ||
""" | ||
|
@@ -345,10 +355,19 @@ def get_state_events(self, user_id, room_id, is_guest=False): | |
) | ||
|
||
if membership == Membership.JOIN: | ||
room_state = yield self.state_handler.get_current_state(room_id) | ||
if at_event: | ||
room_state = yield self.store.get_state_for_events( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we not need to check that the user has permission to view the room at this point? |
||
[at_event], types, filtered_types=filtered_types | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gentle reminder to use trailing commas in this situation. don't mind if you want to leave these now they are done. |
||
) | ||
room_state = room_state[at_event] | ||
else: | ||
state_ids = yield self.store.get_filtered_current_state_ids( | ||
room_id, types, filtered_types=filtered_types | ||
) | ||
room_state = yield self.store.get_events(state_ids.values()) | ||
elif membership == Membership.LEAVE: | ||
room_state = yield self.store.get_state_for_events( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it feels confusing that |
||
[membership_event_id], None | ||
[membership_event_id], types, filtered_types=filtered_types | ||
) | ||
room_state = room_state[membership_event_id] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lower-case
str
, and it can beNone
.also: sorry, but can you copy the slightly longer/clearer descriptions from
get_state_ids_for_events
etc? It's really not obvious how this works from reading this description.