Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
dfbb62c2
Commit
dfbb62c2
authored
5 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Port synaps/rest/client/users.py to async/await
parent
f95325e2
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/rest/admin/users.py
+7
-11
7 additions, 11 deletions
synapse/rest/admin/users.py
with
7 additions
and
11 deletions
synapse/rest/admin/users.py
+
7
−
11
View file @
dfbb62c2
...
...
@@ -14,8 +14,6 @@
# limitations under the License.
import
re
from
twisted.internet
import
defer
from
synapse.api.errors
import
SynapseError
from
synapse.http.servlet
import
(
RestServlet
,
...
...
@@ -59,24 +57,22 @@ class UserAdminServlet(RestServlet):
self
.
auth
=
hs
.
get_auth
()
self
.
handlers
=
hs
.
get_handlers
()
@defer.inlineCallbacks
def
on_GET
(
self
,
request
,
user_id
):
yield
assert_requester_is_admin
(
self
.
auth
,
request
)
async
def
on_GET
(
self
,
request
,
user_id
):
await
assert_requester_is_admin
(
self
.
auth
,
request
)
target_user
=
UserID
.
from_string
(
user_id
)
if
not
self
.
hs
.
is_mine
(
target_user
):
raise
SynapseError
(
400
,
"
Only local users can be admins of this homeserver
"
)
is_admin
=
yield
self
.
handlers
.
admin_handler
.
get_user_server_admin
(
target_user
)
is_admin
=
await
self
.
handlers
.
admin_handler
.
get_user_server_admin
(
target_user
)
is_admin
=
bool
(
is_admin
)
return
200
,
{
"
admin
"
:
is_admin
}
@defer.inlineCallbacks
def
on_PUT
(
self
,
request
,
user_id
):
requester
=
yield
self
.
auth
.
get_user_by_req
(
request
)
yield
assert_user_is_admin
(
self
.
auth
,
requester
.
user
)
async
def
on_PUT
(
self
,
request
,
user_id
):
requester
=
await
self
.
auth
.
get_user_by_req
(
request
)
await
assert_user_is_admin
(
self
.
auth
,
requester
.
user
)
auth_user
=
requester
.
user
target_user
=
UserID
.
from_string
(
user_id
)
...
...
@@ -93,7 +89,7 @@ class UserAdminServlet(RestServlet):
if
target_user
==
auth_user
and
not
set_admin_to
:
raise
SynapseError
(
400
,
"
You may not demote yourself.
"
)
yield
self
.
handlers
.
admin_handler
.
set_user_server_admin
(
await
self
.
handlers
.
admin_handler
.
set_user_server_admin
(
target_user
,
set_admin_to
)
...
...
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