Commit 24a1787f authored by Vamshik Shetty's avatar Vamshik Shetty Committed by Johannes Hayeß
Browse files

add otk account struct

parent ba3cd915
Pipeline #79660 failed with stages
in 23 seconds
......@@ -34,6 +34,11 @@ pub struct OneTimeKeyQueryResponse {
one_time_keys: HashMap<String, HashMap<String, HashMap<String, SignedOneTimeKey>>>,
#[derive(Serialize, Deserialize)]
pub struct AccountOneTimeKeys {
pub curve25519: HashMap<String, String>,
#[derive(Serialize, Deserialize, Clone)]
pub struct SignedOneTimeKey {
pub key: String,
......@@ -15,7 +15,7 @@
// along with this program. If not, see <>.
use crate::endpoints;
use crate::json_objects::otk::{OneTimeKeys, SignedOneTimeKey};
use crate::json_objects::otk::{AccountOneTimeKeys, OneTimeKeys, SignedOneTimeKey};
use crate::packet::{HTTPReqType, M2CPacket, M2CPacketType};
use olm_rs::account::OlmAccount;
use serde_json;
......@@ -77,15 +77,15 @@ impl OTKReplenisher {
// create amount of OTKs to satisfy the replenish goal
olm_account.generate_one_time_keys(self.replenish_goal - otk_count);
let otks_json: serde_json::Value =
let otks_json: AccountOneTimeKeys =
// get the direct mapping of OTK ID to OTK value
let otk_map = otks_json["curve25519"].as_object().unwrap();
let otk_map = otks_json.curve25519;
// construct final query object
let mut signed_otks = OneTimeKeys::new();
for (index, one_time_key) in otk_map.iter() {
let mut key = SignedOneTimeKey::new(one_time_key.as_str().unwrap());
let mut key = SignedOneTimeKey::new(one_time_key.as_str());
let key_signature =
key.set_signature(user_id, device_id, &key_signature);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment