mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-24 09:49:25 -05:00
s/take/claim/ for end to end key APIs
This commit is contained in:
parent
bde97b988a
commit
3b5823c74d
@ -207,9 +207,9 @@ class KeyQueryServlet(RestServlet):
|
|||||||
|
|
||||||
class OneTimeKeyServlet(RestServlet):
|
class OneTimeKeyServlet(RestServlet):
|
||||||
"""
|
"""
|
||||||
GET /keys/take/<user-id>/<device-id>/<algorithm> HTTP/1.1
|
GET /keys/claim/<user-id>/<device-id>/<algorithm> HTTP/1.1
|
||||||
|
|
||||||
POST /keys/take HTTP/1.1
|
POST /keys/claim HTTP/1.1
|
||||||
{
|
{
|
||||||
"one_time_keys": {
|
"one_time_keys": {
|
||||||
"<user_id>": {
|
"<user_id>": {
|
||||||
@ -226,7 +226,7 @@ class OneTimeKeyServlet(RestServlet):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
PATTERN = client_v2_pattern(
|
PATTERN = client_v2_pattern(
|
||||||
"/keys/take(?:/?|(?:/"
|
"/keys/claim(?:/?|(?:/"
|
||||||
"(?P<user_id>[^/]*)/(?P<device_id>[^/]*)/(?P<algorithm>[^/]*)"
|
"(?P<user_id>[^/]*)/(?P<device_id>[^/]*)/(?P<algorithm>[^/]*)"
|
||||||
")?)"
|
")?)"
|
||||||
)
|
)
|
||||||
@ -240,7 +240,7 @@ class OneTimeKeyServlet(RestServlet):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def on_GET(self, request, user_id, device_id, algorithm):
|
def on_GET(self, request, user_id, device_id, algorithm):
|
||||||
yield self.auth.get_user_by_req(request)
|
yield self.auth.get_user_by_req(request)
|
||||||
results = yield self.store.take_e2e_one_time_keys(
|
results = yield self.store.claim_e2e_one_time_keys(
|
||||||
[(user_id, device_id, algorithm)]
|
[(user_id, device_id, algorithm)]
|
||||||
)
|
)
|
||||||
defer.returnValue(self.json_result(request, results))
|
defer.returnValue(self.json_result(request, results))
|
||||||
@ -256,7 +256,7 @@ class OneTimeKeyServlet(RestServlet):
|
|||||||
for user_id, device_keys in body.get("one_time_keys", {}).items():
|
for user_id, device_keys in body.get("one_time_keys", {}).items():
|
||||||
for device_id, algorithm in device_keys.items():
|
for device_id, algorithm in device_keys.items():
|
||||||
query.append((user_id, device_id, algorithm))
|
query.append((user_id, device_id, algorithm))
|
||||||
results = yield self.store.take_e2e_one_time_keys(query)
|
results = yield self.store.claim_e2e_one_time_keys(query)
|
||||||
defer.returnValue(self.json_result(request, results))
|
defer.returnValue(self.json_result(request, results))
|
||||||
|
|
||||||
def json_result(self, request, results):
|
def json_result(self, request, results):
|
||||||
|
@ -95,9 +95,9 @@ class EndToEndKeyStore(SQLBaseStore):
|
|||||||
"count_e2e_one_time_keys", _count_e2e_one_time_keys
|
"count_e2e_one_time_keys", _count_e2e_one_time_keys
|
||||||
)
|
)
|
||||||
|
|
||||||
def take_e2e_one_time_keys(self, query_list):
|
def claim_e2e_one_time_keys(self, query_list):
|
||||||
"""Take a list of one time keys out of the database"""
|
"""Take a list of one time keys out of the database"""
|
||||||
def _take_e2e_one_time_keys(txn):
|
def _claim_e2e_one_time_keys(txn):
|
||||||
sql = (
|
sql = (
|
||||||
"SELECT key_id, key_json FROM e2e_one_time_keys_json"
|
"SELECT key_id, key_json FROM e2e_one_time_keys_json"
|
||||||
" WHERE user_id = ? AND device_id = ? AND algorithm = ?"
|
" WHERE user_id = ? AND device_id = ? AND algorithm = ?"
|
||||||
@ -121,5 +121,5 @@ class EndToEndKeyStore(SQLBaseStore):
|
|||||||
txn.execute(sql, (user_id, device_id, algorithm, key_id))
|
txn.execute(sql, (user_id, device_id, algorithm, key_id))
|
||||||
return result
|
return result
|
||||||
return self.runInteraction(
|
return self.runInteraction(
|
||||||
"take_e2e_one_time_keys", _take_e2e_one_time_keys
|
"claim_e2e_one_time_keys", _claim_e2e_one_time_keys
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user