mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-17 15:31:19 +01:00
Add rest endpoint for the whole user profile
This commit is contained in:
parent
fdcb876495
commit
5c778f2f15
1 changed files with 21 additions and 0 deletions
|
@ -21,6 +21,26 @@ from base import RestServlet, client_path_pattern
|
||||||
import json
|
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):
|
class ProfileDisplaynameRestServlet(RestServlet):
|
||||||
PATTERN = client_path_pattern("/profile/(?P<user_id>[^/]*)/displayname")
|
PATTERN = client_path_pattern("/profile/(?P<user_id>[^/]*)/displayname")
|
||||||
|
|
||||||
|
@ -88,5 +108,6 @@ class ProfileAvatarURLRestServlet(RestServlet):
|
||||||
|
|
||||||
|
|
||||||
def register_servlets(hs, http_server):
|
def register_servlets(hs, http_server):
|
||||||
|
ProfileRestServlet(hs).register(http_server)
|
||||||
ProfileDisplaynameRestServlet(hs).register(http_server)
|
ProfileDisplaynameRestServlet(hs).register(http_server)
|
||||||
ProfileAvatarURLRestServlet(hs).register(http_server)
|
ProfileAvatarURLRestServlet(hs).register(http_server)
|
||||||
|
|
Loading…
Reference in a new issue