account.rs: add some comments (#1799)

This commit is contained in:
Richard van der Hoff 2023-04-20 13:01:44 +01:00 committed by GitHub
parent f2d2a20987
commit 0a0da040d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -402,6 +402,16 @@ impl Account {
/// > subsequently claiming to have sent messages which they didn't.
/// > sender must correspond to the user who sent the event, recipient to
/// > the local user, and recipient_keys to the local Ed25519 key.
///
/// # Arguments
///
/// * `sender` - The `sender` field from the top level of the received
/// event.
/// * `sender_key` - The `sender_key` from the cleartext `content` of the
/// received event (which should also have been used to find or establish
/// the Olm session that was used to decrypt the event -- so it is
/// guaranteed to be correct).
/// * `plaintext` - The decrypted content of the event.
async fn parse_decrypted_to_device_event(
&self,
sender: &UserId,
@ -417,7 +427,10 @@ impl Account {
self.user_id().to_owned(),
)
.into())
} else if event.sender() != sender {
}
// Check that the `sender` in the decrypted to-device event matches that at the
// top level of the encrypted event.
else if event.sender() != sender {
Err(EventError::MismatchedSender(event.sender().to_owned(), sender.to_owned()).into())
} else if identity_keys.ed25519 != event.recipient_keys().ed25519 {
Err(EventError::MismatchedKeys(