From 1b13d7f7ab2fd3aeef8f1a44554a31a3f43136ec Mon Sep 17 00:00:00 2001 From: Stephen D Date: Sun, 25 Aug 2024 15:12:29 -0300 Subject: [PATCH] Fix bug when retrieving keys for an event. It's possible for a server to have multiple associated public keys. This can happen when a Matrix server is set up on a particular domain, its key is lost, and the server continues running on the domain. Now there will be two keys associated to the domain. The old logic wouldn't fetch the new key if we already had the old key cached. The new logic will fetch any keys we don't have that we need, rather than just fetching one key per server. --- src/service/rooms/event_handler.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/service/rooms/event_handler.rs b/src/service/rooms/event_handler.rs index 0e46d524..afd2604d 100644 --- a/src/service/rooms/event_handler.rs +++ b/src/service/rooms/event_handler.rs @@ -1682,8 +1682,13 @@ impl Service { ) })?; + // check that we have the server in our list already, or + // all `signature_ids` are in pub_key_map + // if yes, we don't have to do anything if servers.contains_key(origin) - || pub_key_map.contains_key(origin.as_str()) + || pub_key_map + .get(origin.as_str()) + .is_some_and(contains_all_ids) { continue; }