Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Implement delete_devices API #1993
Conversation
lukebarnard1
assigned
erikjohnston
Mar 13, 2017
lampholder
added
the
in progress
label
Mar 13, 2017
| @@ -45,6 +45,52 @@ def on_GET(self, request): | ||
| ) | ||
| defer.returnValue((200, {"devices": devices})) | ||
| +class DeleteDevicesRestServlet(servlet.RestServlet): | ||
| + PATTERNS = client_v2_patterns("/delete_devices", releases=[], v2_alpha=False) |
erikjohnston
Mar 13, 2017
Owner
Could you add a docstring to say what this and what form the API roughly takes, e.g.:
API for bulk deletion of devices. Accepts a json object with a
deviceskey which lists the device_ids to delete. Requires user interactive auth.
| + """ | ||
| + Args: | ||
| + hs (synapse.server.HomeServer): server | ||
| + """ |
| + def on_POST(self, request): | ||
| + try: | ||
| + body = servlet.parse_json_object_from_request(request) | ||
| + |
| + # the same as those that pass an empty dict | ||
| + body = {} | ||
| + else: | ||
| + raise |
erikjohnston
Mar 13, 2017
Owner
Generally its best to do raise e, as if you later add a yield foo then you will re-raise the wrong error
| + defer.returnValue((401, result)) | ||
| + | ||
| + requester = yield self.auth.get_user_by_req(request) | ||
| + for d_id in body['devices']: |
erikjohnston
Mar 13, 2017
Owner
This is fine for the first cut, but might be nice to change delete_device to delete_devices and then pass around the list through everywhere. This has a number of advantages: a) it reduces work as a lot of things are cheaper to do in bulk, b) it makes it easier to make the API either succeed or fail, rather than partially succeed if something fails halfway through
lukebarnard1
added some commits
Mar 13, 2017
|
PTAL @erikjohnston |
|
what is the rationale for this ooi? (as I thought vector-im/riot-web#2464 was a sufficient fix...) |
|
@ara4n Riot web cheekily implements bulk deletion of devices by caching the password temporarily, if i understand correctly, so I think it makes sense to have a bulk deletion API. (It also means we only notify about device changes once than for each individual device). |
|
lgtm |
|
ok... would be helpful if there was a matching riot bug for this, if nothing else to aid prioritisation relative to the other fires on the riot side (and to ensure the clientside of the api actually gets implemented!) |
|
@ara4n it's on my list of todos, and overlaps nicely with vector-im/riot-web#3268 as it will need a similar multi-select table |
lukebarnard1 commentedMar 13, 2017
•
edited
This implements the proposal here https://docs.google.com/document/d/1C-25Gqz3TXy2jIAoeOKxpNtmme0jI4g3yFGqv5GlAAk for deleting multiple devices using a single request.