diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2014-12-11 10:55:36 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2014-12-11 10:55:36 +0000 |
commit | 0ca072b3b606b54537e1d963c8e0d4b70c2348a4 (patch) | |
tree | 299a79b19eac493826f35b83b6e0dba64a538b4c /synapse/rest/room.py | |
parent | Avoid cyclic dependency in handler setup (diff) | |
download | synapse-0ca072b3b606b54537e1d963c8e0d4b70c2348a4.tar.xz |
Initial tiny hack at REST API for setting room typing notification status
Diffstat (limited to '')
-rw-r--r-- | synapse/rest/room.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/synapse/rest/room.py b/synapse/rest/room.py index 3147d7a60b..e7f28c2784 100644 --- a/synapse/rest/room.py +++ b/synapse/rest/room.py @@ -483,6 +483,37 @@ class RoomRedactEventRestServlet(RestServlet): defer.returnValue(response) +class RoomTypingRestServlet(RestServlet): + PATTERN = client_path_pattern("/rooms/(?P<room_id>[^/]*)/typing/(?P<user_id>[^/]*)$") + + @defer.inlineCallbacks + def on_PUT(self, request, room_id, user_id): + auth_user = yield self.auth.get_user_by_req(request) + + room_id = urllib.unquote(room_id) + target_user = self.hs.parse_userid(urllib.unquote(user_id)) + + content = _parse_json(request) + + typing_handler = self.handlers.typing_notification_handler + + if content["typing"]: + yield typing_handler.started_typing( + target_user=target_user, + auth_user=auth_user, + room_id=room_id, + timeout=content.get("timeout", 30000), + ) + else: + yield typing_handler.stopped_typing( + target_user=target_user, + auth_user=auth_user, + room_id=room_id, + ) + + defer.returnValue((200, {})) + + def _parse_json(request): try: content = json.loads(request.content.read()) @@ -538,3 +569,4 @@ def register_servlets(hs, http_server): RoomStateRestServlet(hs).register(http_server) RoomInitialSyncRestServlet(hs).register(http_server) RoomRedactEventRestServlet(hs).register(http_server) + RoomTypingRestServlet(hs).register(http_server) |