Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5099 +/- ##
==========================================
- Coverage 85.14% 85.13% -0.01%
==========================================
Files 329 329
Lines 36912 36939 +27
==========================================
+ Hits 31429 31449 +20
- Misses 5483 5490 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| false // Exclude events with no type or encrypted | ||
| } | ||
| }) | ||
| .map(matrix_sdk_common::deserialized_responses::ProcessedToDeviceEvent::PlainText) |
There was a problem hiding this comment.
When there is no encryption, to-device are not processed by the olm machine. There is no UnProcessed variant of ProcessedToDeviceEvent (not sure it would make sense :/).
So anyhow, we can just ignore the encrypted to-device as they are useless. So we can just map to PlainText variant?
I wonder if we should at some point remove the optional e2e-encryption feature flag
There was a problem hiding this comment.
Huh, but how are events we fail to decrypt treated? Why not treat them just like that?
andybalaam
left a comment
There was a problem hiding this comment.
Looks sensible to me. A couple of optional minor comments.
| let captured_info: Arc<Mutex<Option<EncryptionInfo>>> = Arc::new(Mutex::new(None)); | ||
|
|
||
| client.add_event_handler({ | ||
| let captured = captured_event.clone(); |
There was a problem hiding this comment.
I'd prefer this to be called captured_event too.
| let captured_info = captured_info.clone(); | ||
| move |ev: AnyToDeviceEvent, encryption_info: Option<EncryptionInfo>| { | ||
| let mut captured_lock = captured.lock(); | ||
| *captured_lock = Some(ev); |
There was a problem hiding this comment.
Can we lock and update in the same line of code? Might be nicer?
poljar
left a comment
There was a problem hiding this comment.
Alright, I think most of this looks good and makes sense.
I don't think we should completely filter out UTDs in case E2EE is disabled at compile time, the rest are small nits.
| false // Exclude events with no type or encrypted | ||
| } | ||
| }) | ||
| .map(matrix_sdk_common::deserialized_responses::ProcessedToDeviceEvent::PlainText) |
There was a problem hiding this comment.
Huh, but how are events we fail to decrypt treated? Why not treat them just like that?
| .field( | ||
| "to_device", | ||
| &DebugListOfRawEventsNoId( | ||
| self.to_device.iter().map(|p| p.to_raw()).collect::<Vec<_>>().as_slice(), |
There was a problem hiding this comment.
Feels a bit expensive to clone the whole thing for a debug output, can't we have an as_raw() that will borrow the thing instead?
There was a problem hiding this comment.
I did a similar thing to DebugListOfRawEventsNoId for list of processed to device 3eaaa30
| } | ||
|
|
||
| // let bob be aware of Alice keys in order to be able to decrypt custom | ||
| // to-device (the device keys check are not delayed for non-crypto to-device |
There was a problem hiding this comment.
I think they are in fact only delayed or rather deferred for m.room.key events since dropping those would lead to a lot of UTDs.
There was a problem hiding this comment.
I clarified (I am not sure what is exactly done for key bundles, but no need to go in details here)
poljar
left a comment
There was a problem hiding this comment.
I think this is now good to go, we just need to fix the changelog entry.
To double check, this isn't a breaking change, right? Existing event handlers will continue on working, they'll just ignore the new EncryptionInfo field.
| - `Client::add_event_handler`: Set `Option<EncryptionInfo>` in `EventHandlerData` for to-device messages. | ||
| If the to-device message was encrypted, the `EncryptionInfo` will be set. If it is `None` the message was sent in clear. | ||
| ([#5099](https://github.com/matrix-org/matrix-rust-sdk/pull/5099)) |
There was a problem hiding this comment.
This has been put in the wrong place, it's not part of the 0.12.0 release.
There was a problem hiding this comment.
oh right, got hit by the merge. d92eceb
To double check, this isn't a breaking change, right? Existing event handlers will continue on working
Yes no change for existing event handlers.
Existing event handlers for to_device that requested the EncryptionInfo were always getting None, now they will get something if the event was encrypted.
poljar
left a comment
There was a problem hiding this comment.
Thanks, looks good now.
Should I just squash merge?
... which includes matrix-org/matrix-rust-sdk#5099, which moves `ProcessedToDeviceEvent` to matrix-sdk-common.
Main change
In
event_handler/mod.rsthere is a new methodhandle_sync_to_device_events(..)that will dispatch the to-device messages with the olm variant ofEncryptionInfo.The sync response struct
SyncResponsenow havepub to_device: Vec<ProcessedToDeviceEvent>instead of the oldpub to_device: Vec<Raw<AnyToDeviceEvent>>Context
It is now possible to get an Olm
EncryptionInfowhen register an event handler for to-device messages (previously the encryption_info was alwaysNonefor to-device`.Make it possible to make a difference between a plaintext and a successfully decrypted to-device message.
There is now a new variant of
EncryptionInfothat will be passed to the to-device event handlers.There might be a change that would be better to review alone 125aec6
=> I needed to move
ProcessedToDeviceEventfrom thecryptocrate to the commoncrate. If not it was making it complex to compile with thee2efeature not enabled. This is the same reason why SyncTimelineEvent/UnableToDecryptReason/Encryption info are already in the common crate.Based on #5074
Signed-off-by: