0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-01 04:09:07 +01:00

Merge branch 'new_state_resolution' of github.com:matrix-org/synapse into rejections_storage

This commit is contained in:
Erik Johnston 2015-01-30 14:04:53 +00:00
commit 875a481a1e

View file

@ -37,13 +37,15 @@ def _get_state_key_from_event(event):
KeyStateTuple = namedtuple("KeyStateTuple", ("context", "type", "state_key")) KeyStateTuple = namedtuple("KeyStateTuple", ("context", "type", "state_key"))
AuthEventTypes = (EventTypes.Create, EventTypes.Member, EventTypes.PowerLevels,)
class StateHandler(object): class StateHandler(object):
""" Responsible for doing state conflict resolution. """ Responsible for doing state conflict resolution.
""" """
def __init__(self, hs): def __init__(self, hs):
self.store = hs.get_datastore() self.store = hs.get_datastore()
# self.auth = hs.get_auth()
self.hs = hs self.hs = hs
@defer.inlineCallbacks @defer.inlineCallbacks
@ -215,7 +217,7 @@ class StateHandler(object):
auth_events = { auth_events = {
k: e for k, e in unconflicted_state.items() k: e for k, e in unconflicted_state.items()
if k[0] in (EventTypes.Create, EventTypes.Member, EventTypes.PowerLevels,) if k[0] in AuthEventTypes
} }
try: try:
@ -240,10 +242,6 @@ class StateHandler(object):
1. power levels 1. power levels
2. memberships 2. memberships
3. other events. 3. other events.
:param conflicted_state:
:param auth_events:
:return:
""" """
resolved_state = {} resolved_state = {}
power_key = (EventTypes.PowerLevels, "") power_key = (EventTypes.PowerLevels, "")
@ -295,7 +293,7 @@ class StateHandler(object):
# get around circular deps. # get around circular deps.
self.hs.get_auth().check(event, auth_events) self.hs.get_auth().check(event, auth_events)
return event return event
except AuthError as e: except AuthError:
pass pass
# Oh dear. # Oh dear.
@ -305,4 +303,4 @@ class StateHandler(object):
def key_func(e): def key_func(e):
return -int(e.depth), hashlib.sha1(e.event_id).hexdigest() return -int(e.depth), hashlib.sha1(e.event_id).hexdigest()
return sorted(events, key=key_func) return sorted(events, key=key_func)