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
Container registry
Model registry
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
Maunium
synapse
Commits
b2596c66
Commit
b2596c66
authored
10 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Add a few more comments to the federation handler
parent
e715741a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/handlers/federation.py
+32
-0
32 additions, 0 deletions
synapse/handlers/federation.py
with
32 additions
and
0 deletions
synapse/handlers/federation.py
+
32
−
0
View file @
b2596c66
...
@@ -40,6 +40,8 @@ class FederationHandler(BaseHandler):
...
@@ -40,6 +40,8 @@ class FederationHandler(BaseHandler):
of the home server (including auth and state conflict resoultion)
of the home server (including auth and state conflict resoultion)
b) converting events that were produced by local clients that may need
b) converting events that were produced by local clients that may need
to be sent to remote home servers.
to be sent to remote home servers.
c) doing the necessary dances to invite remote users and join remote
rooms.
"""
"""
def
__init__
(
self
,
hs
):
def
__init__
(
self
,
hs
):
...
@@ -102,6 +104,8 @@ class FederationHandler(BaseHandler):
...
@@ -102,6 +104,8 @@ class FederationHandler(BaseHandler):
logger
.
debug
(
"
Got event: %s
"
,
event
.
event_id
)
logger
.
debug
(
"
Got event: %s
"
,
event
.
event_id
)
# If we are currently in the process of joining this room, then we
# queue up events for later processing.
if
event
.
room_id
in
self
.
room_queues
:
if
event
.
room_id
in
self
.
room_queues
:
self
.
room_queues
[
event
.
room_id
].
append
(
pdu
)
self
.
room_queues
[
event
.
room_id
].
append
(
pdu
)
return
return
...
@@ -187,6 +191,8 @@ class FederationHandler(BaseHandler):
...
@@ -187,6 +191,8 @@ class FederationHandler(BaseHandler):
@log_function
@log_function
@defer.inlineCallbacks
@defer.inlineCallbacks
def
backfill
(
self
,
dest
,
room_id
,
limit
):
def
backfill
(
self
,
dest
,
room_id
,
limit
):
"""
Trigger a backfill request to `dest` for the given `room_id`
"""
extremities
=
yield
self
.
store
.
get_oldest_events_in_room
(
room_id
)
extremities
=
yield
self
.
store
.
get_oldest_events_in_room
(
room_id
)
pdus
=
yield
self
.
replication_layer
.
backfill
(
pdus
=
yield
self
.
replication_layer
.
backfill
(
...
@@ -212,6 +218,10 @@ class FederationHandler(BaseHandler):
...
@@ -212,6 +218,10 @@ class FederationHandler(BaseHandler):
@defer.inlineCallbacks
@defer.inlineCallbacks
def
send_invite
(
self
,
target_host
,
event
):
def
send_invite
(
self
,
target_host
,
event
):
"""
Sends the invite to the remote server for signing.
Invites must be signed by the invitee
'
s server before distribution.
"""
pdu
=
yield
self
.
replication_layer
.
send_invite
(
pdu
=
yield
self
.
replication_layer
.
send_invite
(
destination
=
target_host
,
destination
=
target_host
,
context
=
event
.
room_id
,
context
=
event
.
room_id
,
...
@@ -229,6 +239,17 @@ class FederationHandler(BaseHandler):
...
@@ -229,6 +239,17 @@ class FederationHandler(BaseHandler):
@log_function
@log_function
@defer.inlineCallbacks
@defer.inlineCallbacks
def
do_invite_join
(
self
,
target_host
,
room_id
,
joinee
,
content
,
snapshot
):
def
do_invite_join
(
self
,
target_host
,
room_id
,
joinee
,
content
,
snapshot
):
"""
Attempts to join the `joinee` to the room `room_id` via the
server `target_host`.
This first triggers a /make_join/ request that returns a partial
event that we can fill out and sign. This is then sent to the
remote server via /send_join/ which responds with the state at that
event and the auth_chains.
We suspend processing of any received events from this room until we
have finished processing the join.
"""
pdu
=
yield
self
.
replication_layer
.
make_join
(
pdu
=
yield
self
.
replication_layer
.
make_join
(
target_host
,
target_host
,
room_id
,
room_id
,
...
@@ -313,6 +334,10 @@ class FederationHandler(BaseHandler):
...
@@ -313,6 +334,10 @@ class FederationHandler(BaseHandler):
@defer.inlineCallbacks
@defer.inlineCallbacks
@log_function
@log_function
def
on_make_join_request
(
self
,
context
,
user_id
):
def
on_make_join_request
(
self
,
context
,
user_id
):
"""
We
'
ve received a /make_join/ request, so we create a partial
join event for the room and return that. We don *not* persist or
process it until the other server has signed it and sent it back.
"""
event
=
self
.
event_factory
.
create_event
(
event
=
self
.
event_factory
.
create_event
(
etype
=
RoomMemberEvent
.
TYPE
,
etype
=
RoomMemberEvent
.
TYPE
,
content
=
{
"
membership
"
:
Membership
.
JOIN
},
content
=
{
"
membership
"
:
Membership
.
JOIN
},
...
@@ -335,6 +360,9 @@ class FederationHandler(BaseHandler):
...
@@ -335,6 +360,9 @@ class FederationHandler(BaseHandler):
@defer.inlineCallbacks
@defer.inlineCallbacks
@log_function
@log_function
def
on_send_join_request
(
self
,
origin
,
pdu
):
def
on_send_join_request
(
self
,
origin
,
pdu
):
"""
We have received a join event for a room. Fully process it and
respond with the current state and auth chains.
"""
event
=
self
.
pdu_codec
.
event_from_pdu
(
pdu
)
event
=
self
.
pdu_codec
.
event_from_pdu
(
pdu
)
event
.
outlier
=
False
event
.
outlier
=
False
...
@@ -403,6 +431,10 @@ class FederationHandler(BaseHandler):
...
@@ -403,6 +431,10 @@ class FederationHandler(BaseHandler):
@defer.inlineCallbacks
@defer.inlineCallbacks
def
on_invite_request
(
self
,
origin
,
pdu
):
def
on_invite_request
(
self
,
origin
,
pdu
):
"""
We
'
ve got an invite event. Process and persist it. Sign it.
Respond with the now signed event.
"""
event
=
self
.
pdu_codec
.
event_from_pdu
(
pdu
)
event
=
self
.
pdu_codec
.
event_from_pdu
(
pdu
)
event
.
outlier
=
True
event
.
outlier
=
True
...
...
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