mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Pull out full state less
This commit is contained in:
parent
721414d98a
commit
0e1900d819
@ -278,18 +278,19 @@ class Auth(object):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def check_host_in_room(self, room_id, host):
|
def check_host_in_room(self, room_id, host):
|
||||||
curr_state = yield self.state.get_current_state(room_id)
|
curr_state_id = yield self.state.get_current_state_ids(room_id)
|
||||||
|
|
||||||
for event in curr_state.values():
|
for (etype, state_key), event_id in curr_state_id.items():
|
||||||
if event.type == EventTypes.Member:
|
if etype == EventTypes.Member:
|
||||||
try:
|
try:
|
||||||
if get_domain_from_id(event.state_key) != host:
|
if get_domain_from_id(state_key) != host:
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
logger.warn("state_key not user_id: %s", event.state_key)
|
logger.warn("state_key not user_id: %s", state_key)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if event.content["membership"] == Membership.JOIN:
|
event = yield self.store.get_event(event_id, allow_none=True)
|
||||||
|
if event and event.content["membership"] == Membership.JOIN:
|
||||||
defer.returnValue(True)
|
defer.returnValue(True)
|
||||||
|
|
||||||
defer.returnValue(False)
|
defer.returnValue(False)
|
||||||
|
@ -95,15 +95,19 @@ class StateHandler(object):
|
|||||||
|
|
||||||
_, state = yield self.resolve_state_groups(room_id, latest_event_ids)
|
_, state = yield self.resolve_state_groups(room_id, latest_event_ids)
|
||||||
|
|
||||||
|
if event_type:
|
||||||
|
event_id = state.get((event_type, state_key))
|
||||||
|
event = None
|
||||||
|
if event_id:
|
||||||
|
event = yield self.store.get_event(event_id, allow_none=True)
|
||||||
|
defer.returnValue(event)
|
||||||
|
return
|
||||||
|
|
||||||
state_map = yield self.store.get_events(state.values(), get_prev_content=False)
|
state_map = yield self.store.get_events(state.values(), get_prev_content=False)
|
||||||
state = {
|
state = {
|
||||||
key: state_map[e_id] for key, e_id in state.items() if e_id in state_map
|
key: state_map[e_id] for key, e_id in state.items() if e_id in state_map
|
||||||
}
|
}
|
||||||
|
|
||||||
if event_type:
|
|
||||||
defer.returnValue(state.get((event_type, state_key)))
|
|
||||||
return
|
|
||||||
|
|
||||||
defer.returnValue(state)
|
defer.returnValue(state)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
Loading…
Reference in New Issue
Block a user