add a tonne of docstring; make upload_room_keys properly assert version
This commit is contained in:
parent
9f500cb39e
commit
9f0791b7bd
|
@ -67,6 +67,7 @@ class EndToEndRoomKeyStore(SQLBaseStore):
|
||||||
version(str): the version ID of the backup we're updating
|
version(str): the version ID of the backup we're updating
|
||||||
room_id(str): the ID of the room whose keys we're setting
|
room_id(str): the ID of the room whose keys we're setting
|
||||||
session_id(str): the session whose room_key we're setting
|
session_id(str): the session whose room_key we're setting
|
||||||
|
room_key(dict): the room_key being set
|
||||||
Raises:
|
Raises:
|
||||||
StoreError if stuff goes wrong, probably
|
StoreError if stuff goes wrong, probably
|
||||||
"""
|
"""
|
||||||
|
@ -182,34 +183,45 @@ class EndToEndRoomKeyStore(SQLBaseStore):
|
||||||
desc="delete_e2e_room_keys",
|
desc="delete_e2e_room_keys",
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
def get_e2e_room_keys_version_info(self, user_id, version=None):
|
||||||
def get_e2e_room_keys_version_info(self, user_id, version):
|
"""Get info metadata about a version of our room_keys backup.
|
||||||
"""Get info etadata about a given version of our room_keys backup
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
user_id(str): the user whose backup we're querying
|
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:
|
Returns:
|
||||||
A deferred dict giving the info metadata for this backup version
|
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):
|
||||||
table="e2e_room_keys_versions",
|
if version is None:
|
||||||
keyvalues={
|
txn.execute(
|
||||||
"user_id": user_id,
|
"SELECT MAX(version) FROM e2e_room_keys_versions WHERE user_id=?",
|
||||||
"version": version,
|
(user_id,)
|
||||||
},
|
)
|
||||||
retcols=(
|
version = txn.fetchone()[0]
|
||||||
"user_id",
|
|
||||||
"version",
|
|
||||||
"algorithm",
|
|
||||||
"auth_data",
|
|
||||||
),
|
|
||||||
desc="get_e2e_room_keys_version_info",
|
|
||||||
)
|
|
||||||
|
|
||||||
defer.returnValue(row)
|
return self._simple_select_one_txn(
|
||||||
|
table="e2e_room_keys_versions",
|
||||||
|
keyvalues={
|
||||||
|
"user_id": user_id,
|
||||||
|
"version": version,
|
||||||
|
},
|
||||||
|
retcols=(
|
||||||
|
"user_id",
|
||||||
|
"version",
|
||||||
|
"algorithm",
|
||||||
|
"auth_data",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
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):
|
def create_e2e_room_keys_version(self, user_id, info):
|
||||||
"""Atomically creates a new version of this user's e2e_room_keys store
|
"""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):
|
def _create_e2e_room_keys_version_txn(txn):
|
||||||
|
|
||||||
txn.execute(
|
txn.execute(
|
||||||
"SELECT MAX(version) FROM e2e_room_keys_versions WHERE user_id=?",
|
"SELECT MAX(version) FROM e2e_room_keys_versions WHERE user_id=?",
|
||||||
(user_id,)
|
(user_id,)
|
||||||
|
|
Loading…
Reference in New Issue