mirror of
https://mau.dev/maunium/synapse.git
synced 2024-09-10 11:51:57 +02:00
Fix application of ACLs
This commit is contained in:
parent
10b874067b
commit
1b994a97dd
4 changed files with 33 additions and 17 deletions
|
@ -229,7 +229,7 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
@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):
|
||||||
states = yield self.store.get_state_for_events(
|
event_to_state = yield self.store.get_state_for_events(
|
||||||
room_id, frozenset(e.event_id for e in events),
|
room_id, frozenset(e.event_id for e in events),
|
||||||
types=(
|
types=(
|
||||||
(EventTypes.RoomHistoryVisibility, ""),
|
(EventTypes.RoomHistoryVisibility, ""),
|
||||||
|
@ -237,8 +237,6 @@ class FederationHandler(BaseHandler):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
events_and_states = zip(events, states)
|
|
||||||
|
|
||||||
def redact_disallowed(event_and_state):
|
def redact_disallowed(event_and_state):
|
||||||
event, state = event_and_state
|
event, state = event_and_state
|
||||||
|
|
||||||
|
@ -275,9 +273,10 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
return event
|
return event
|
||||||
|
|
||||||
res = map(redact_disallowed, events_and_states)
|
res = map(redact_disallowed, [
|
||||||
|
(e, event_to_state[e.event_id])
|
||||||
logger.info("_filter_events_for_server %r", res)
|
for e in events
|
||||||
|
])
|
||||||
|
|
||||||
defer.returnValue(res)
|
defer.returnValue(res)
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ class MessageHandler(BaseHandler):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _filter_events_for_client(self, user_id, room_id, events):
|
def _filter_events_for_client(self, user_id, room_id, events):
|
||||||
states = yield self.store.get_state_for_events(
|
event_id_to_state = yield self.store.get_state_for_events(
|
||||||
room_id, frozenset(e.event_id for e in events),
|
room_id, frozenset(e.event_id for e in events),
|
||||||
types=(
|
types=(
|
||||||
(EventTypes.RoomHistoryVisibility, ""),
|
(EventTypes.RoomHistoryVisibility, ""),
|
||||||
|
@ -145,7 +145,8 @@ class MessageHandler(BaseHandler):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
events_and_states = zip(events, states)
|
for ev, state in event_id_to_state.items():
|
||||||
|
logger.info("event_id: %r, state: %r", ev, state)
|
||||||
|
|
||||||
def allowed(event_and_state):
|
def allowed(event_and_state):
|
||||||
event, state = event_and_state
|
event, state = event_and_state
|
||||||
|
@ -179,10 +180,17 @@ class MessageHandler(BaseHandler):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
events_and_states = filter(allowed, events_and_states)
|
event_and_state = filter(
|
||||||
|
allowed,
|
||||||
|
[
|
||||||
|
(e, event_id_to_state[e.event_id])
|
||||||
|
for e in events
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
defer.returnValue([
|
defer.returnValue([
|
||||||
ev
|
ev
|
||||||
for ev, _ in events_and_states
|
for ev, _ in event_and_state
|
||||||
])
|
])
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
|
@ -294,7 +294,7 @@ class SyncHandler(BaseHandler):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _filter_events_for_client(self, user_id, room_id, events):
|
def _filter_events_for_client(self, user_id, room_id, events):
|
||||||
states = yield self.store.get_state_for_events(
|
event_id_to_state = yield self.store.get_state_for_events(
|
||||||
room_id, frozenset(e.event_id for e in events),
|
room_id, frozenset(e.event_id for e in events),
|
||||||
types=(
|
types=(
|
||||||
(EventTypes.RoomHistoryVisibility, ""),
|
(EventTypes.RoomHistoryVisibility, ""),
|
||||||
|
@ -302,7 +302,8 @@ class SyncHandler(BaseHandler):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
events_and_states = zip(events, states)
|
for ev, state in event_id_to_state.items():
|
||||||
|
logger.info("event_id: %r, state: %r", ev, state)
|
||||||
|
|
||||||
def allowed(event_and_state):
|
def allowed(event_and_state):
|
||||||
event, state = event_and_state
|
event, state = event_and_state
|
||||||
|
@ -335,10 +336,18 @@ class SyncHandler(BaseHandler):
|
||||||
return membership == Membership.INVITE
|
return membership == Membership.INVITE
|
||||||
|
|
||||||
return True
|
return True
|
||||||
events_and_states = filter(allowed, events_and_states)
|
|
||||||
|
event_and_state = filter(
|
||||||
|
allowed,
|
||||||
|
[
|
||||||
|
(e, event_id_to_state[e.event_id])
|
||||||
|
for e in events
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
defer.returnValue([
|
defer.returnValue([
|
||||||
ev
|
ev
|
||||||
for ev, _ in events_and_states
|
for ev, _ in event_and_state
|
||||||
])
|
])
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
|
@ -239,10 +239,10 @@ class StateStore(SQLBaseStore):
|
||||||
for event_id, group in event_to_groups.items()
|
for event_id, group in event_to_groups.items()
|
||||||
}
|
}
|
||||||
|
|
||||||
defer.returnValue([
|
defer.returnValue({
|
||||||
event_to_state[event]
|
event: event_to_state[event]
|
||||||
for event in event_ids
|
for event in event_ids
|
||||||
])
|
})
|
||||||
|
|
||||||
@cached(num_args=2, lru=True, max_entries=100000)
|
@cached(num_args=2, lru=True, max_entries=100000)
|
||||||
def _get_state_group_for_event(self, room_id, event_id):
|
def _get_state_group_for_event(self, room_id, event_id):
|
||||||
|
|
Loading…
Reference in a new issue