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
68f34e85
Commit
68f34e85
authored
7 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Use transport client directly
parent
3e703eb0
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/groups_local.py
+25
-18
25 additions, 18 deletions
synapse/handlers/groups_local.py
with
25 additions
and
18 deletions
synapse/handlers/groups_local.py
+
25
−
18
View file @
68f34e85
...
@@ -32,15 +32,17 @@ logger = logging.getLogger(__name__)
...
@@ -32,15 +32,17 @@ logger = logging.getLogger(__name__)
# TODO: Add group memebership /sync
# TODO: Add group memebership /sync
def
_create_rerouter
(
name
):
def
_create_rerouter
(
func_name
):
"""
Returns a function that looks at the group id and calls the function
on federation or the local group server if the group is local
"""
def
f
(
self
,
group_id
,
*
args
,
**
kwargs
):
def
f
(
self
,
group_id
,
*
args
,
**
kwargs
):
if
self
.
is_mine_id
(
group_id
):
if
self
.
is_mine_id
(
group_id
):
return
getattr
(
self
.
groups_server_handler
,
name
)(
return
getattr
(
self
.
groups_server_handler
,
func_
name
)(
group_id
,
*
args
,
**
kwargs
group_id
,
*
args
,
**
kwargs
)
)
repl_layer
=
self
.
hs
.
get_replication_layer
()
return
getattr
(
self
.
transport_client
,
func_name
)(
group_id
,
*
args
,
**
kwargs
)
return
getattr
(
repl_layer
,
name
)(
group_id
,
*
args
,
**
kwargs
)
return
f
return
f
...
@@ -50,6 +52,7 @@ class GroupsLocalHandler(object):
...
@@ -50,6 +52,7 @@ class GroupsLocalHandler(object):
self
.
store
=
hs
.
get_datastore
()
self
.
store
=
hs
.
get_datastore
()
self
.
room_list_handler
=
hs
.
get_room_list_handler
()
self
.
room_list_handler
=
hs
.
get_room_list_handler
()
self
.
groups_server_handler
=
hs
.
get_groups_server_handler
()
self
.
groups_server_handler
=
hs
.
get_groups_server_handler
()
self
.
transport_client
=
hs
.
get_federation_transport_client
()
self
.
auth
=
hs
.
get_auth
()
self
.
auth
=
hs
.
get_auth
()
self
.
clock
=
hs
.
get_clock
()
self
.
clock
=
hs
.
get_clock
()
self
.
keyring
=
hs
.
get_keyring
()
self
.
keyring
=
hs
.
get_keyring
()
...
@@ -82,15 +85,19 @@ class GroupsLocalHandler(object):
...
@@ -82,15 +85,19 @@ class GroupsLocalHandler(object):
@defer.inlineCallbacks
@defer.inlineCallbacks
def
get_group_summary
(
self
,
group_id
,
requester_user_id
):
def
get_group_summary
(
self
,
group_id
,
requester_user_id
):
"""
Get the group summary for a group.
If the group is remote we check that the users have valid attestations.
"""
if
self
.
is_mine_id
(
group_id
):
if
self
.
is_mine_id
(
group_id
):
res
=
yield
self
.
groups_server_handler
.
get_group_summary
(
res
=
yield
self
.
groups_server_handler
.
get_group_summary
(
group_id
,
requester_user_id
group_id
,
requester_user_id
)
)
defer
.
returnValue
(
res
)
defer
.
returnValue
(
res
)
repl_layer
=
self
.
hs
.
get_replication_layer
()
res
=
yield
self
.
transport_client
.
get_group_summary
(
group_id
,
requester_user_id
)
res
=
yield
repl_layer
.
get_group_summary
(
group_id
,
requester_user_id
)
# Loop through the users and validate the attestations.
chunk
=
res
[
"
users_section
"
][
"
users
"
]
chunk
=
res
[
"
users_section
"
][
"
users
"
]
valid_users
=
[]
valid_users
=
[]
for
entry
in
chunk
:
for
entry
in
chunk
:
...
@@ -121,8 +128,7 @@ class GroupsLocalHandler(object):
...
@@ -121,8 +128,7 @@ class GroupsLocalHandler(object):
group_id
,
user_id
,
content
group_id
,
user_id
,
content
)
)
repl_layer
=
self
.
hs
.
get_replication_layer
()
return
self
.
transport_client
.
create_group
(
group_id
,
user_id
,
content
)
# TODO
return
repl_layer
.
create_group
(
group_id
,
user_id
,
content
)
# TODO
def
add_room
(
self
,
group_id
,
user_id
,
room_id
,
content
):
def
add_room
(
self
,
group_id
,
user_id
,
room_id
,
content
):
if
self
.
is_mine_id
(
group_id
):
if
self
.
is_mine_id
(
group_id
):
...
@@ -130,8 +136,9 @@ class GroupsLocalHandler(object):
...
@@ -130,8 +136,9 @@ class GroupsLocalHandler(object):
group_id
,
user_id
,
room_id
,
content
group_id
,
user_id
,
room_id
,
content
)
)
repl_layer
=
self
.
hs
.
get_replication_layer
()
return
self
.
transport_client
.
add_room_to_group
(
return
repl_layer
.
add_room_to_group
(
group_id
,
user_id
,
room_id
,
content
)
# TODO
group_id
,
user_id
,
room_id
,
content
,
)
# TODO
@defer.inlineCallbacks
@defer.inlineCallbacks
def
get_users_in_group
(
self
,
group_id
,
requester_user_id
):
def
get_users_in_group
(
self
,
group_id
,
requester_user_id
):
...
@@ -141,8 +148,9 @@ class GroupsLocalHandler(object):
...
@@ -141,8 +148,9 @@ class GroupsLocalHandler(object):
)
)
defer
.
returnValue
(
res
)
defer
.
returnValue
(
res
)
repl_layer
=
self
.
hs
.
get_replication_layer
()
res
=
yield
self
.
transport_client
.
get_users_in_group
(
res
=
yield
repl_layer
.
get_users_in_group
(
group_id
,
requester_user_id
)
# TODO
group_id
,
requester_user_id
,
)
# TODO
chunk
=
res
[
"
chunk
"
]
chunk
=
res
[
"
chunk
"
]
valid_entries
=
[]
valid_entries
=
[]
...
@@ -179,8 +187,9 @@ class GroupsLocalHandler(object):
...
@@ -179,8 +187,9 @@ class GroupsLocalHandler(object):
local_attestation
=
self
.
attestations
.
create_attestation
(
group_id
,
user_id
)
local_attestation
=
self
.
attestations
.
create_attestation
(
group_id
,
user_id
)
content
[
"
attestation
"
]
=
local_attestation
content
[
"
attestation
"
]
=
local_attestation
repl_layer
=
self
.
hs
.
get_replication_layer
()
res
=
yield
self
.
transport_client
.
accept_group_invite
(
res
=
yield
repl_layer
.
accept_group_invite
(
group_id
,
user_id
,
content
)
group_id
,
user_id
,
content
,
)
remote_attestation
=
res
[
"
attestation
"
]
remote_attestation
=
res
[
"
attestation
"
]
...
@@ -211,8 +220,7 @@ class GroupsLocalHandler(object):
...
@@ -211,8 +220,7 @@ class GroupsLocalHandler(object):
group_id
,
user_id
,
requester_user_id
,
content
,
group_id
,
user_id
,
requester_user_id
,
content
,
)
)
else
:
else
:
repl_layer
=
self
.
hs
.
get_replication_layer
()
res
=
yield
self
.
transport_client
.
invite_to_group
(
res
=
yield
repl_layer
.
invite_to_group
(
group_id
,
user_id
,
content
,
group_id
,
user_id
,
content
,
)
)
...
@@ -257,8 +265,7 @@ class GroupsLocalHandler(object):
...
@@ -257,8 +265,7 @@ class GroupsLocalHandler(object):
)
)
else
:
else
:
content
[
"
requester_user_id
"
]
=
requester_user_id
content
[
"
requester_user_id
"
]
=
requester_user_id
repl_layer
=
self
.
hs
.
get_replication_layer
()
res
=
yield
self
.
transport_client
.
remove_user_from_group
(
res
=
yield
repl_layer
.
remove_user_from_group
(
group_id
,
user_id
,
content
group_id
,
user_id
,
content
)
# TODO
)
# TODO
...
...
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