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
bc1fa8cd
Commit
bc1fa8cd
authored
6 years ago
by
Travis Ralston
Committed by
Richard van der Hoff
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add GET account data routes (#4303)
As per
https://github.com/matrix-org/matrix-doc/issues/1339
parent
b7c02188
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/4303.feature
+1
-0
1 addition, 0 deletions
changelog.d/4303.feature
synapse/rest/client/v2_alpha/account_data.py
+33
-1
33 additions, 1 deletion
synapse/rest/client/v2_alpha/account_data.py
with
34 additions
and
1 deletion
changelog.d/4303.feature
0 → 100644
+
1
−
0
View file @
bc1fa8cd
Add
routes
for
reading
account
data.
This diff is collapsed.
Click to expand it.
synapse/rest/client/v2_alpha/account_data.py
+
33
−
1
View file @
bc1fa8cd
...
...
@@ -17,7 +17,7 @@ import logging
from
twisted.internet
import
defer
from
synapse.api.errors
import
AuthError
,
SynapseError
from
synapse.api.errors
import
AuthError
,
NotFoundError
,
SynapseError
from
synapse.http.servlet
import
RestServlet
,
parse_json_object_from_request
from
._base
import
client_v2_patterns
...
...
@@ -28,6 +28,7 @@ logger = logging.getLogger(__name__)
class
AccountDataServlet
(
RestServlet
):
"""
PUT /user/{user_id}/account_data/{account_dataType} HTTP/1.1
GET /user/{user_id}/account_data/{account_dataType} HTTP/1.1
"""
PATTERNS
=
client_v2_patterns
(
"
/user/(?P<user_id>[^/]*)/account_data/(?P<account_data_type>[^/]*)
"
...
...
@@ -57,10 +58,26 @@ class AccountDataServlet(RestServlet):
defer
.
returnValue
((
200
,
{}))
@defer.inlineCallbacks
def
on_GET
(
self
,
request
,
user_id
,
account_data_type
):
requester
=
yield
self
.
auth
.
get_user_by_req
(
request
)
if
user_id
!=
requester
.
user
.
to_string
():
raise
AuthError
(
403
,
"
Cannot get account data for other users.
"
)
event
=
yield
self
.
store
.
get_global_account_data_by_type_for_user
(
account_data_type
,
user_id
,
)
if
event
is
None
:
raise
NotFoundError
(
"
Account data not found
"
)
defer
.
returnValue
((
200
,
event
))
class
RoomAccountDataServlet
(
RestServlet
):
"""
PUT /user/{user_id}/rooms/{room_id}/account_data/{account_dataType} HTTP/1.1
GET /user/{user_id}/rooms/{room_id}/account_data/{account_dataType} HTTP/1.1
"""
PATTERNS
=
client_v2_patterns
(
"
/user/(?P<user_id>[^/]*)
"
...
...
@@ -99,6 +116,21 @@ class RoomAccountDataServlet(RestServlet):
defer
.
returnValue
((
200
,
{}))
@defer.inlineCallbacks
def
on_GET
(
self
,
request
,
user_id
,
room_id
,
account_data_type
):
requester
=
yield
self
.
auth
.
get_user_by_req
(
request
)
if
user_id
!=
requester
.
user
.
to_string
():
raise
AuthError
(
403
,
"
Cannot get account data for other users.
"
)
event
=
yield
self
.
store
.
get_account_data_for_room_and_type
(
user_id
,
room_id
,
account_data_type
,
)
if
event
is
None
:
raise
NotFoundError
(
"
Room account data not found
"
)
defer
.
returnValue
((
200
,
event
))
def
register_servlets
(
hs
,
http_server
):
AccountDataServlet
(
hs
).
register
(
http_server
)
...
...
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