original_docstring: Take a list of one time keys out of the database
docstring: Take a list of one time keys out of the database
docstring_tokens: Take a list of one time keys out of the database
code: def claim_e2e_one_time_keys(self, query_list):
          """Take a list of one time keys out of the database"""
          def _claim_e2e_one_time_keys(txn):
              sql = (
                  "SELECT key_id, key_json FROM e2e_one_time_keys_json"
                  " WHERE user_id = ? AND device_id = ? AND algorithm = ?"
                  " LIMIT 1"
              )
              result = {}
              delete = []
              for user_id, device_id, algorithm in query_list:
                  user_result = result.setdefault(user_id, {})
                  device_result = user_result.setdefault(device_id, {})
                  txn.execute(sql, (user_id, device_id, algorithm))
                  for key_id, key_json in txn:
                      device_result[algorithm + ":" + key_id] = key_json
                      delete.append((user_id, device_id, algorithm, key_id))
              sql = (
                  "DELETE FROM e2e_one_time_keys_json"
                  " WHERE user_id = ? AND device_id = ? AND algorithm = ?"
                  " AND key_id = ?"
              )
              for user_id, device_id, algorithm, key_id in delete:
                  txn.execute(sql, (user_id, device_id, algorithm, key_id))
              return result
          return self.runInteraction(
              "claim_e2e_one_time_keys", _claim_e2e_one_time_keys
          )
code_tokens: def claim_e2e_one_time_keys ( self , query_list ) : def _claim_e2e_one_time_keys ( txn ) : sql = ( "SELECT key_id, key_json FROM e2e_one_time_keys_json" " WHERE user_id = ? AND device_id = ? AND algorithm = ?" " LIMIT 1" ) result = { } delete = [ ] for user_id , device_id , algorithm in query_list : user_result = result . setdefault ( user_id , { } ) device_result = user_result . setdefault ( device_id , { } ) txn . execute ( sql , ( user_id , device_id , algorithm ) ) for key_id , key_json in txn : device_result [ algorithm + ":" + key_id ] = key_json delete . append ( ( user_id , device_id , algorithm , key_id ) ) sql = ( "DELETE FROM e2e_one_time_keys_json" " WHERE user_id = ? AND device_id = ? AND algorithm = ?" " AND key_id = ?" ) for user_id , device_id , algorithm , key_id in delete : txn . execute ( sql , ( user_id , device_id , algorithm , key_id ) ) return result return self . runInteraction ( "claim_e2e_one_time_keys" , _claim_e2e_one_time_keys )
short_docstring: Take a list of one time keys out of the database
short_docstring_tokens: Take a list of one time keys out of the database
comment: """Take a list of one time keys out of the database"""