add count and hash when deleting keys

This commit is contained in:
Hubert Chathi 2019-08-15 20:26:08 -07:00
parent 0355a75285
commit d081883f1e
2 changed files with 18 additions and 3 deletions

View file

@ -101,13 +101,25 @@ class E2eRoomKeysHandler(object):
session_id(string): session ID to delete keys for, for None to delete keys
for all sessions
Returns:
A deferred of the deletion transaction
A dict containing the count and hash for the backup version
"""
# lock for consistency with uploading
with (yield self._upload_linearizer.queue(user_id)):
# make sure the backup version exists
try:
version_info = yield self.store.get_e2e_room_keys_version_info(user_id, version)
except StoreError as e:
if e.code == 404:
raise NotFoundError("Unknown backup version")
else:
raise
yield self.store.delete_e2e_room_keys(user_id, version, room_id, session_id)
count = yield self.store.count_e2e_room_keys(user_id, version)
return {"count": count, "hash": version_info["hash"]}
@defer.inlineCallbacks
def upload_room_keys(self, user_id, version, room_keys):
"""Bulk upload a list of room keys into a given backup version, asserting
@ -134,6 +146,9 @@ class E2eRoomKeysHandler(object):
}
}
Returns:
A dict containing the count and hash for the backup version
Raises:
NotFoundError: if there are no versions defined
RoomKeysVersionError: if the uploaded version is not the current version

View file

@ -239,10 +239,10 @@ class RoomKeysServlet(RestServlet):
user_id = requester.user.to_string()
version = parse_string(request, "version")
yield self.e2e_room_keys_handler.delete_room_keys(
ret = yield self.e2e_room_keys_handler.delete_room_keys(
user_id, version, room_id, session_id
)
return (200, {})
return (200, ret)
class RoomKeysNewVersionServlet(RestServlet):