Skip to content

Commit

Permalink
crypto: Simplify the interface of search_for_device
Browse files Browse the repository at this point in the history
  • Loading branch information
andybalaam committed Jul 23, 2024
1 parent 2045b32 commit 99da0ff
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use ruma::UserId;
use tracing::error;
use vodozemac::Curve25519PublicKey;

Expand Down Expand Up @@ -150,20 +151,20 @@ impl<'a> SenderDataFinder<'a> {
self.have_device_keys(sender_device_keys).await
} else {
// No: look for the device in the store
self.search_for_device(sender_curve_key, room_key_event).await
self.search_for_device(sender_curve_key, &room_key_event.sender).await
}
}

/// Step B (there are no device keys in the to-device message)
async fn search_for_device(
&self,
sender_curve_key: Curve25519PublicKey,
room_key_event: &'a DecryptedRoomKeyEvent,
sender_user_id: &UserId,
) -> OlmResult<SenderData> {
// Does the locally-cached (in the store) devices list contain a device with the
// curve key of the sender of the to-device message?
if let Some(sender_device) =
self.store.get_device_from_curve_key(&room_key_event.sender, sender_curve_key).await?
self.store.get_device_from_curve_key(sender_user_id, sender_curve_key).await?
{
// Yes: use the device to continue
self.have_device(sender_device)
Expand Down

0 comments on commit 99da0ff

Please sign in to comment.