Merge branch 'develop' of github.com:matrix-org/synapse into matrix-org-hotfixes
commit
c0128c1021
|
@ -80,7 +80,7 @@ class E2eKeysHandler(object):
|
||||||
else:
|
else:
|
||||||
remote_queries[user_id] = device_ids
|
remote_queries[user_id] = device_ids
|
||||||
|
|
||||||
# Firt get local devices.
|
# First get local devices.
|
||||||
failures = {}
|
failures = {}
|
||||||
results = {}
|
results = {}
|
||||||
if local_query:
|
if local_query:
|
||||||
|
|
|
@ -460,6 +460,47 @@ class FederationHandler(BaseHandler):
|
||||||
@measure_func("_filter_events_for_server")
|
@measure_func("_filter_events_for_server")
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _filter_events_for_server(self, server_name, room_id, events):
|
def _filter_events_for_server(self, server_name, room_id, events):
|
||||||
|
"""Filter the given events for the given server, redacting those the
|
||||||
|
server can't see.
|
||||||
|
|
||||||
|
Assumes the server is currently in the room.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
list[FrozenEvent]
|
||||||
|
"""
|
||||||
|
# First lets check to see if all the events have a history visibility
|
||||||
|
# of "shared" or "world_readable". If thats the case then we don't
|
||||||
|
# need to check membership (as we know the server is in the room).
|
||||||
|
event_to_state_ids = yield self.store.get_state_ids_for_events(
|
||||||
|
frozenset(e.event_id for e in events),
|
||||||
|
types=(
|
||||||
|
(EventTypes.RoomHistoryVisibility, ""),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
visibility_ids = set()
|
||||||
|
for sids in event_to_state_ids.itervalues():
|
||||||
|
hist = sids.get((EventTypes.RoomHistoryVisibility, ""))
|
||||||
|
if hist:
|
||||||
|
visibility_ids.add(hist)
|
||||||
|
|
||||||
|
# If we failed to find any history visibility events then the default
|
||||||
|
# is "shared" visiblity.
|
||||||
|
if not visibility_ids:
|
||||||
|
defer.returnValue(events)
|
||||||
|
|
||||||
|
event_map = yield self.store.get_events(visibility_ids)
|
||||||
|
all_open = all(
|
||||||
|
e.content.get("history_visibility") in (None, "shared", "world_readable")
|
||||||
|
for e in event_map.itervalues()
|
||||||
|
)
|
||||||
|
|
||||||
|
if all_open:
|
||||||
|
defer.returnValue(events)
|
||||||
|
|
||||||
|
# Ok, so we're dealing with events that have non-trivial visibility
|
||||||
|
# rules, so we need to also get the memberships of the room.
|
||||||
|
|
||||||
event_to_state_ids = yield self.store.get_state_ids_for_events(
|
event_to_state_ids = yield self.store.get_state_ids_for_events(
|
||||||
frozenset(e.event_id for e in events),
|
frozenset(e.event_id for e in events),
|
||||||
types=(
|
types=(
|
||||||
|
|
|
@ -146,7 +146,7 @@ class SyncResult(collections.namedtuple("SyncResult", [
|
||||||
"invited", # InvitedSyncResult for each invited room.
|
"invited", # InvitedSyncResult for each invited room.
|
||||||
"archived", # ArchivedSyncResult for each archived room.
|
"archived", # ArchivedSyncResult for each archived room.
|
||||||
"to_device", # List of direct messages for the device.
|
"to_device", # List of direct messages for the device.
|
||||||
"device_lists", # List of user_ids whose devices have chanegd
|
"device_lists", # List of user_ids whose devices have changed
|
||||||
"device_one_time_keys_count", # Dict of algorithm to count for one time keys
|
"device_one_time_keys_count", # Dict of algorithm to count for one time keys
|
||||||
# for this device
|
# for this device
|
||||||
"groups",
|
"groups",
|
||||||
|
|
Loading…
Reference in New Issue