summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-02-13 14:20:05 +0000
committerErik Johnston <erik@matrix.org>2015-02-13 14:20:05 +0000
commit8c652a2b5f4ed07abd682543ad6a365c6d50b8d3 (patch)
treeb6913b1d6ca63e2159ea2515e11f024fa4b056ca /synapse/handlers
parentMerge branch 'master' of github.com:matrix-org/synapse into develop (diff)
downloadsynapse-8c652a2b5f4ed07abd682543ad6a365c6d50b8d3.tar.xz
When we see a difference in current state, actually use state conflict resolution algorithm
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/federation.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index 77c81fe2da..5b225ffb57 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -858,6 +858,40 @@ class FederationHandler(BaseHandler):
             # Do auth conflict res.
             logger.debug("Different auth: %s", different_auth)
 
+            different_events = yield defer.gatherResults(
+                [
+                    self.store.get_event(
+                        d,
+                        allow_none=True,
+                        allow_rejected=False,
+                    )
+                    for d in different_auth
+                    if d in have_events and not have_events[d]
+                ],
+                consumeErrors=True
+            )
+
+            if different_events:
+                local_view = dict(auth_events)
+                remote_view = dict(auth_events)
+                remote_view.update({
+                    (d.type, d.state_key) for d in different_events
+                })
+
+                new_state, _ = self.state.resolve_events(
+                    [local_view, remote_view],
+                    event
+                )
+
+                auth_events.update(new_state)
+
+                current_state = set(e.event_id for e in auth_events.values())
+                different_auth = event_auth_events - current_state
+
+                context.current_state.update(auth_events)
+                context.state_group = None
+
+        if different_auth and not event.internal_metadata.is_outlier():
             # Only do auth resolution if we have something new to say.
             # We can't rove an auth failure.
             do_resolution = False