Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
7dd1c5c5
Commit
7dd1c5c5
authored
10 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Neaten the handling of state and auth_chain up a bit
parent
9bace3a3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/handlers/federation.py
+30
-27
30 additions, 27 deletions
synapse/handlers/federation.py
with
30 additions
and
27 deletions
synapse/handlers/federation.py
+
30
−
27
View file @
7dd1c5c5
...
...
@@ -30,6 +30,7 @@ from synapse.types import UserID
from
twisted.internet
import
defer
import
itertools
import
logging
...
...
@@ -112,14 +113,6 @@ class FederationHandler(BaseHandler):
logger
.
debug
(
"
Event: %s
"
,
event
)
event_ids
=
set
()
if
state
:
event_ids
|=
{
e
.
event_id
for
e
in
state
}
if
auth_chain
:
event_ids
|=
{
e
.
event_id
for
e
in
auth_chain
}
seen_ids
=
(
yield
self
.
store
.
have_events
(
event_ids
)).
keys
()
# FIXME (erikj): Awful hack to make the case where we are not currently
# in the room work
current_state
=
None
...
...
@@ -131,27 +124,37 @@ class FederationHandler(BaseHandler):
logger
.
debug
(
"
Got event for room we
'
re not in.
"
)
current_state
=
state
event_ids
=
set
()
if
state
:
event_ids
|=
{
e
.
event_id
for
e
in
state
}
if
auth_chain
:
event_ids
|=
{
e
.
event_id
for
e
in
auth_chain
}
seen_ids
=
(
yield
self
.
store
.
have_events
(
event_ids
)).
keys
()
if
state
and
auth_chain
is
not
None
:
for
list_of_pdus
in
[
auth_chain
,
state
]:
for
e
in
list_of_pdus
:
if
e
.
event_id
in
seen_ids
:
continue
# If we have any state or auth_chain given to us by the replication
# layer, then we should handle them (if we haven't before.)
for
e
in
itertools
.
chain
(
auth_chain
,
state
):
if
e
.
event_id
in
seen_ids
:
continue
e
.
internal_metadata
.
outlier
=
True
try
:
auth_ids
=
[
e_id
for
e_id
,
_
in
e
.
auth_events
]
auth
=
{
(
e
.
type
,
e
.
state_key
):
e
for
e
in
auth_chain
if
e
.
event_id
in
auth_ids
}
yield
self
.
_handle_new_event
(
origin
,
e
,
auth_events
=
auth
)
except
:
logger
.
exception
(
"
Failed to handle state event %s
"
,
e
.
event_id
,
)
e
.
internal_metadata
.
outlier
=
True
try
:
auth_ids
=
[
e_id
for
e_id
,
_
in
e
.
auth_events
]
auth
=
{
(
e
.
type
,
e
.
state_key
):
e
for
e
in
auth_chain
if
e
.
event_id
in
auth_ids
}
yield
self
.
_handle_new_event
(
origin
,
e
,
auth_events
=
auth
)
seen_ids
.
add
(
e
.
event_id
)
except
:
logger
.
exception
(
"
Failed to handle state event %s
"
,
e
.
event_id
,
)
try
:
yield
self
.
_handle_new_event
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment