summary refs log tree commit diff
path: root/synapse/rest/room.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-12-15 14:45:59 +0000
committerErik Johnston <erik@matrix.org>2014-12-15 14:45:59 +0000
commit57e0e619f3ddc68673a0d7b345203b1a52ff1fa1 (patch)
treed7c45715bc9313f7602243b1cd614d95d1a24858 /synapse/rest/room.py
parentAdd beginnings of upgrade script (diff)
parentStill send typing notifications to myself if I'm the only one in the room (it... (diff)
downloadsynapse-57e0e619f3ddc68673a0d7b345203b1a52ff1fa1.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into events_refactor
Conflicts:
	tests/handlers/test_room.py
Diffstat (limited to 'synapse/rest/room.py')
-rw-r--r--synapse/rest/room.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/synapse/rest/room.py b/synapse/rest/room.py
index 7fb5aca0a7..25ee964555 100644
--- a/synapse/rest/room.py
+++ b/synapse/rest/room.py
@@ -466,6 +466,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())
@@ -521,3 +552,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)