diff options
author | David Baker <dbkr@matrix.org> | 2014-09-02 11:48:52 +0100 |
---|---|---|
committer | David Baker <dbkr@matrix.org> | 2014-09-02 11:49:17 +0100 |
commit | 5c778f2f15553ce8478b5094e0ed91eda3c011b2 (patch) | |
tree | 11a3250a1f6946e783174773712eef3443a6d7ce | |
parent | More ban spec. Added 'name' and 'topic' keys to /createRoom. (diff) | |
download | synapse-5c778f2f15553ce8478b5094e0ed91eda3c011b2.tar.xz |
Add rest endpoint for the whole user profile
-rw-r--r-- | synapse/rest/profile.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/synapse/rest/profile.py b/synapse/rest/profile.py index 2f010c0182..e454ca4661 100644 --- a/synapse/rest/profile.py +++ b/synapse/rest/profile.py @@ -21,6 +21,26 @@ from base import RestServlet, client_path_pattern import json +class ProfileRestServlet(RestServlet): + PATTERN = client_path_pattern("/profile/(?P<user_id>[^/]*)") + + @defer.inlineCallbacks + def on_GET(self, request, user_id): + user = self.hs.parse_userid(user_id) + + displayname = yield self.handlers.profile_handler.get_displayname( + user, + ) + avatar_url = yield self.handlers.profile_handler.get_avatar_url( + user, + ) + + defer.returnValue((200, { + "displayname": displayname, + "avatar_url": avatar_url + })) + + class ProfileDisplaynameRestServlet(RestServlet): PATTERN = client_path_pattern("/profile/(?P<user_id>[^/]*)/displayname") @@ -88,5 +108,6 @@ class ProfileAvatarURLRestServlet(RestServlet): def register_servlets(hs, http_server): + ProfileRestServlet(hs).register(http_server) ProfileDisplaynameRestServlet(hs).register(http_server) ProfileAvatarURLRestServlet(hs).register(http_server) |