crypto: Simplify the Olm message map construction.

master
Damir Jelić 2020-08-20 10:19:55 +02:00
parent 58185e08e8
commit aaa15c768c
1 changed files with 7 additions and 10 deletions

View File

@ -1080,13 +1080,10 @@ impl OlmMachine {
Err(e) => return Err(e),
};
if !messages.contains_key(device.user_id()) {
messages.insert(device.user_id().clone(), BTreeMap::new());
};
let user_messages = messages.get_mut(device.user_id()).unwrap();
user_messages.insert(
messages
.entry(device.user_id().clone())
.or_insert(BTreeMap::new())
.insert(
DeviceIdOrAllDevices::DeviceId(device.device_id().into()),
serde_json::value::to_raw_value(&encrypted)?,
);