diff options
author | Erik Johnston <erik@matrix.org> | 2016-07-29 11:24:56 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-07-29 11:24:56 +0100 |
commit | 5aa024e50132924d50229c633249a17eff9180f1 (patch) | |
tree | 5b0ee152c49f6a772bcb4e133fd4649aa612bda3 /synapse/storage/devices.py | |
parent | Add destination retry to slave store (diff) | |
parent | Merge pull request #966 from matrix-org/markjh/fix_push (diff) | |
download | synapse-5aa024e50132924d50229c633249a17eff9180f1.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/fed_reader
Diffstat (limited to 'synapse/storage/devices.py')
-rw-r--r-- | synapse/storage/devices.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/synapse/storage/devices.py b/synapse/storage/devices.py index 1cc6e07f2b..afd6530cab 100644 --- a/synapse/storage/devices.py +++ b/synapse/storage/devices.py @@ -76,6 +76,46 @@ class DeviceStore(SQLBaseStore): desc="get_device", ) + def delete_device(self, user_id, device_id): + """Delete a device. + + Args: + user_id (str): The ID of the user which owns the device + device_id (str): The ID of the device to delete + Returns: + defer.Deferred + """ + return self._simple_delete_one( + table="devices", + keyvalues={"user_id": user_id, "device_id": device_id}, + desc="delete_device", + ) + + def update_device(self, user_id, device_id, new_display_name=None): + """Update a device. + + Args: + user_id (str): The ID of the user which owns the device + device_id (str): The ID of the device to update + new_display_name (str|None): new displayname for device; None + to leave unchanged + Raises: + StoreError: if the device is not found + Returns: + defer.Deferred + """ + updates = {} + if new_display_name is not None: + updates["display_name"] = new_display_name + if not updates: + return defer.succeed(None) + return self._simple_update_one( + table="devices", + keyvalues={"user_id": user_id, "device_id": device_id}, + updatevalues=updates, + desc="update_device", + ) + @defer.inlineCallbacks def get_devices_by_user(self, user_id): """Retrieve all of a user's registered devices. |