summary refs log tree commit diff
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2020-08-04 16:10:49 -0400
committerHubert Chathi <hubert@uhoreg.ca>2020-08-04 16:10:49 -0400
commitb59bc664e6d200a17ce2d0bb03863b80b359768b (patch)
tree993d40e11bb9cf0a35355fa8a130dd8f28db597e
parentadd changelog (diff)
downloadsynapse-b59bc664e6d200a17ce2d0bb03863b80b359768b.tar.xz
minor fixes
-rw-r--r--synapse/handlers/device.py2
-rw-r--r--synapse/rest/client/v1/login.py2
-rw-r--r--synapse/storage/data_stores/main/devices.py3
-rw-r--r--tests/rest/client/v1/test_login.py30
4 files changed, 17 insertions, 20 deletions
diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py
index 0923466db4..8995be8446 100644
--- a/synapse/handlers/device.py
+++ b/synapse/handlers/device.py
@@ -562,7 +562,7 @@ class DeviceHandler(DeviceWorkerHandler):
 
     async def cancel_rehydrate(self, token: str) -> dict:
         # FIXME: if can't find token, return 404
-        token_info = await self.store.clear_dehydration_token(token)
+        token_info = await self.store.clear_dehydration_token(token, False)
         # create device and access token from original login submission
         login_submission = token_info.get("login_submission")
         device_id = login_submission.get("device_id")
diff --git a/synapse/rest/client/v1/login.py b/synapse/rest/client/v1/login.py
index 6a03ccf40e..9e6748d4d1 100644
--- a/synapse/rest/client/v1/login.py
+++ b/synapse/rest/client/v1/login.py
@@ -424,7 +424,7 @@ class LoginRestServlet(RestServlet):
 
 
 class RestoreDeviceServlet(RestServlet):
-    PATTERNS = client_patterns("/org.matrix.msc26997/restore_device")
+    PATTERNS = client_patterns("/org.matrix.msc2697/restore_device")
 
     def __init__(self, hs):
         super(RestoreDeviceServlet, self).__init__()
diff --git a/synapse/storage/data_stores/main/devices.py b/synapse/storage/data_stores/main/devices.py
index 8555d47ad4..0ad4846463 100644
--- a/synapse/storage/data_stores/main/devices.py
+++ b/synapse/storage/data_stores/main/devices.py
@@ -729,6 +729,7 @@ class DeviceWorkerStore(SQLBaseStore):
         )
 
     async def get_dehydrated_device(self, user_id: str) -> Tuple[str, str]:
+        # FIXME: make sure device ID still exists in devices table
         row = await self.db.simple_select_one(
             table="dehydrated_devices",
             keyvalues={"user_id": user_id},
@@ -761,7 +762,7 @@ class DeviceWorkerStore(SQLBaseStore):
             self.db.simple_update_txn(
                 txn,
                 table="dehydrated_devices",
-                keyvalues={"user_id", user_id},
+                keyvalues={"user_id": user_id},
                 updatevalues={"device_id": device_id, "device_data": device_data,},
             )
         return old_device_id
diff --git a/tests/rest/client/v1/test_login.py b/tests/rest/client/v1/test_login.py
index cafa581be7..d0c3f40e78 100644
--- a/tests/rest/client/v1/test_login.py
+++ b/tests/rest/client/v1/test_login.py
@@ -779,13 +779,12 @@ class DehydrationTestCase(unittest.HomeserverTestCase):
         access_token = self.login("kermit", "monkey")
 
         # dehydrate a device
-        params = json.dumps({
-            "device_data": "foobar"
-        })
+        params = json.dumps({"device_data": "foobar"})
         request, channel = self.make_request(
-            b"POST", b"/_matrix/client/unstable/org.matrix.msc2697/device/dehydrate",
+            b"POST",
+            b"/_matrix/client/unstable/org.matrix.msc2697/device/dehydrate",
             params,
-            access_token=access_token
+            access_token=access_token,
         )
         self.render(request)
         self.assertEquals(channel.code, 200, channel.result)
@@ -798,25 +797,22 @@ class DehydrationTestCase(unittest.HomeserverTestCase):
         self.render(request)
 
         # log in, requesting a dehydrated device
-        params = json.dumps({
-            "type": "m.login.password",
-            "user": "kermit",
-            "password": "monkey",
-            "org.matrix.msc2697.restore_device": True,
-        })
-        request, channel = self.make_request(
-            "POST", "/_matrix/client/r0/login", params
+        params = json.dumps(
+            {
+                "type": "m.login.password",
+                "user": "kermit",
+                "password": "monkey",
+                "org.matrix.msc2697.restore_device": True,
+            }
         )
+        request, channel = self.make_request("POST", "/_matrix/client/r0/login", params)
         self.render(request)
         self.assertEqual(channel.code, 200, channel.result)
         self.assertEqual(channel.json_body["device_data"], "foobar")
         self.assertEqual(channel.json_body["device_id"], dehydrated_device_id)
         dehydration_token = channel.json_body["dehydration_token"]
 
-        params = json.dumps({
-            "rehydrate": True,
-            "dehydration_token": dehydration_token
-        })
+        params = json.dumps({"rehydrate": True, "dehydration_token": dehydration_token})
         request, channel = self.make_request(
             "POST", "/_matrix/client/unstable/org.matrix.msc2697/restore_device", params
         )