summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-07-25 17:51:24 +0100
committerRichard van der Hoff <richard@matrix.org>2016-07-26 07:35:48 +0100
commit012b4c19132d57fdbc1b6b0e304eb60eaf19200f (patch)
tree93570c6bc031416b50061e3bc1f83fb519dca007 /synapse/handlers
parentImplement deleting devices (diff)
downloadsynapse-012b4c19132d57fdbc1b6b0e304eb60eaf19200f.tar.xz
Implement updating devices
You can update the displayname of devices now.
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/device.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py
index a7a192e1c9..9e65d85e6d 100644
--- a/synapse/handlers/device.py
+++ b/synapse/handlers/device.py
@@ -141,6 +141,30 @@ class DeviceHandler(BaseHandler):
         yield self.store.user_delete_access_tokens(user_id,
                                                    device_id=device_id)
 
+    @defer.inlineCallbacks
+    def update_device(self, user_id, device_id, content):
+        """ Update the given device
+
+        Args:
+            user_id (str):
+            device_id (str):
+            content (dict): body of update request
+
+        Returns:
+            defer.Deferred:
+        """
+
+        try:
+            yield self.store.update_device(
+                user_id,
+                device_id,
+                new_display_name=content.get("display_name")
+            )
+        except errors.StoreError, e:
+            if e.code == 404:
+                raise errors.NotFoundError()
+            else:
+                raise
 
 
 def _update_device_from_client_ips(device, client_ips):