Skip to content

Commit

Permalink
crypto: Verified identity changes Fix test with memory store
Browse files Browse the repository at this point in the history
Clone of identities prevent detect changes due shared Arc. Force serializing/deserializing
  • Loading branch information
BillCarsonFr committed Aug 2, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
DRSchlaubi Michael Rittmeister
1 parent 28ecc2b commit ce9e0f9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crates/matrix-sdk-crypto/src/store/memorystore.rs
Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ pub struct MemoryStore {
tracked_users: StdRwLock<HashMap<OwnedUserId, TrackedUser>>,
olm_hashes: StdRwLock<HashMap<String, HashSet<String>>>,
devices: DeviceStore,
identities: StdRwLock<HashMap<OwnedUserId, UserIdentityData>>,
identities: StdRwLock<HashMap<OwnedUserId, String>>,
outgoing_key_requests: StdRwLock<HashMap<OwnedTransactionId, GossipRequest>>,
key_requests_by_info: StdRwLock<HashMap<String, OwnedTransactionId>>,
direct_withheld_info: StdRwLock<HashMap<OwnedRoomId, HashMap<String, RoomKeyWithheldEvent>>>,
@@ -231,7 +231,10 @@ impl CryptoStore for MemoryStore {
{
let mut identities = self.identities.write().unwrap();
for identity in changes.identities.new.into_iter().chain(changes.identities.changed) {
identities.insert(identity.user_id().to_owned(), identity.clone());
identities.insert(
identity.user_id().to_owned(),
serde_json::to_string(&identity).unwrap(),
);
}
}

@@ -481,7 +484,14 @@ impl CryptoStore for MemoryStore {
}

async fn get_user_identity(&self, user_id: &UserId) -> Result<Option<UserIdentityData>> {
Ok(self.identities.read().unwrap().get(user_id).cloned())
let serialized = self.identities.read().unwrap().get(user_id).cloned();
match serialized {
None => Ok(None),
Some(serialized) => {
let id: UserIdentityData = serde_json::from_str(serialized.as_str()).unwrap();
Ok(Some(id))
}
}
}

async fn is_message_known(&self, message_hash: &crate::olm::OlmMessageHash) -> Result<bool> {

0 comments on commit ce9e0f9

Please sign in to comment.