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
6eb3aa94
Commit
6eb3aa94
authored
7 years ago
by
Luke Barnard
Browse files
Options
Downloads
Patches
Plain Diff
Factor out add_user from accept_invite and join_group
parent
edb45aae
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/groups/groups_server.py
+29
-41
29 additions, 41 deletions
synapse/groups/groups_server.py
with
29 additions
and
41 deletions
synapse/groups/groups_server.py
+
29
−
41
View file @
6eb3aa94
...
...
@@ -678,30 +678,21 @@ class GroupsServerHandler(object):
raise
SynapseError
(
502
,
"
Unknown state returned by HS
"
)
@defer.inlineCallbacks
def
a
ccept_invite
(
self
,
group_id
,
requester_
user_id
,
content
):
"""
User tries to accept an invite to the group
.
def
a
dd_user
(
self
,
group_id
,
user_id
,
content
):
"""
Add a user to a group based on a content dict
.
This is different from them asking to join, and so should error if no
invite exists (and they
'
re not a member of the group)
See accept_invite, join_group.
"""
yield
self
.
check_group_is_ours
(
group_id
,
requester_user_id
,
and_exists
=
True
)
is_invited
=
yield
self
.
store
.
is_user_invited_to_local_group
(
group_id
,
requester_user_id
,
)
if
not
is_invited
:
raise
SynapseError
(
403
,
"
User not invited to group
"
)
if
not
self
.
hs
.
is_mine_id
(
requester_user_id
):
if
not
self
.
hs
.
is_mine_id
(
user_id
):
local_attestation
=
self
.
attestations
.
create_attestation
(
group_id
,
requester_
user_id
,
group_id
,
user_id
,
)
remote_attestation
=
content
[
"
attestation
"
]
yield
self
.
attestations
.
verify_attestation
(
remote_attestation
,
user_id
=
requester_
user_id
,
user_id
=
user_id
,
group_id
=
group_id
,
)
else
:
...
...
@@ -711,13 +702,33 @@ class GroupsServerHandler(object):
is_public
=
_parse_visibility_from_contents
(
content
)
yield
self
.
store
.
add_user_to_group
(
group_id
,
requester_
user_id
,
group_id
,
user_id
,
is_admin
=
False
,
is_public
=
is_public
,
local_attestation
=
local_attestation
,
remote_attestation
=
remote_attestation
,
)
defer
.
returnValue
(
local_attestation
)
@defer.inlineCallbacks
def
accept_invite
(
self
,
group_id
,
requester_user_id
,
content
):
"""
User tries to accept an invite to the group.
This is different from them asking to join, and so should error if no
invite exists (and they
'
re not a member of the group)
"""
yield
self
.
check_group_is_ours
(
group_id
,
requester_user_id
,
and_exists
=
True
)
is_invited
=
yield
self
.
store
.
is_user_invited_to_local_group
(
group_id
,
requester_user_id
,
)
if
not
is_invited
:
raise
SynapseError
(
403
,
"
User not invited to group
"
)
local_attestation
=
yield
self
.
add_user
(
group_id
,
requester_user_id
,
content
)
defer
.
returnValue
({
"
state
"
:
"
join
"
,
"
attestation
"
:
local_attestation
,
...
...
@@ -738,30 +749,7 @@ class GroupsServerHandler(object):
if
not
group_info
[
'
is_joinable
'
]:
raise
SynapseError
(
403
,
"
Group is not publicly joinable
"
)
if
not
self
.
hs
.
is_mine_id
(
requester_user_id
):
local_attestation
=
self
.
attestations
.
create_attestation
(
group_id
,
requester_user_id
,
)
remote_attestation
=
content
[
"
attestation
"
]
yield
self
.
attestations
.
verify_attestation
(
remote_attestation
,
user_id
=
requester_user_id
,
group_id
=
group_id
,
)
else
:
local_attestation
=
None
remote_attestation
=
None
is_public
=
_parse_visibility_from_contents
(
content
)
yield
self
.
store
.
add_user_to_group
(
group_id
,
requester_user_id
,
is_admin
=
False
,
is_public
=
is_public
,
local_attestation
=
local_attestation
,
remote_attestation
=
remote_attestation
,
)
local_attestation
=
yield
self
.
add_user
(
group_id
,
requester_user_id
,
content
)
defer
.
returnValue
({
"
state
"
:
"
join
"
,
...
...
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