add a tonne of docstring; make upload_room_keys properly assert version

This commit is contained in:
Matthew Hodgson 2017-12-27 23:35:10 +00:00 committed by Hubert Chathi
parent 9f500cb39e
commit 9f0791b7bd
1 changed files with 32 additions and 21 deletions

View File

@ -67,6 +67,7 @@ class EndToEndRoomKeyStore(SQLBaseStore):
version(str): the version ID of the backup we're updating
room_id(str): the ID of the room whose keys we're setting
session_id(str): the session whose room_key we're setting
room_key(dict): the room_key being set
Raises:
StoreError if stuff goes wrong, probably
"""
@ -182,19 +183,28 @@ class EndToEndRoomKeyStore(SQLBaseStore):
desc="delete_e2e_room_keys",
)
@defer.inlineCallbacks
def get_e2e_room_keys_version_info(self, user_id, version):
"""Get info etadata about a given version of our room_keys backup
def get_e2e_room_keys_version_info(self, user_id, version=None):
"""Get info metadata about a version of our room_keys backup.
Args:
user_id(str): the user whose backup we're querying
version(str): the version ID of the backup we're querying about
version(str): Optional. the version ID of the backup we're querying about
If missing, we return the information about the current version.
Raises:
StoreError: with code 404 if there are no e2e_room_keys_versions present
Returns:
A deferred dict giving the info metadata for this backup version
"""
row = yield self._simple_select_one(
def _get_e2e_room_keys_version_info_txn(txn):
if version is None:
txn.execute(
"SELECT MAX(version) FROM e2e_room_keys_versions WHERE user_id=?",
(user_id,)
)
version = txn.fetchone()[0]
return self._simple_select_one_txn(
table="e2e_room_keys_versions",
keyvalues={
"user_id": user_id,
@ -206,10 +216,12 @@ class EndToEndRoomKeyStore(SQLBaseStore):
"algorithm",
"auth_data",
),
desc="get_e2e_room_keys_version_info",
)
defer.returnValue(row)
return self.runInteraction(
desc="get_e2e_room_keys_version_info",
_get_e2e_room_keys_version_info_txn
)
def create_e2e_room_keys_version(self, user_id, info):
"""Atomically creates a new version of this user's e2e_room_keys store
@ -224,7 +236,6 @@ class EndToEndRoomKeyStore(SQLBaseStore):
"""
def _create_e2e_room_keys_version_txn(txn):
txn.execute(
"SELECT MAX(version) FROM e2e_room_keys_versions WHERE user_id=?",
(user_id,)