matrix-org / matrix-rust-sdk

Matrix Client-Server SDK for Rust
Apache License 2.0
1.26k stars 251 forks source link

UTD Hook | Add support for late decryption grace period for parity with Web #4265

Open BillCarsonFr opened 7 hours ago

BillCarsonFr commented 7 hours ago

On web we have a configurable grace period for late key delivery https://github.com/element-hq/element-web/blob/9a126795a81d13aba2d331b38df75878682d54a1/src/DecryptionFailureTracker.ts#L122

    /** If the event is successfully decrypted in less than 4s, we don't report. */
    public static GRACE_PERIOD_MS = 4000;

There is no similar mecanism with the rust UTD hook, the late decryption are never graced https://github.com/matrix-org/matrix-rust-sdk/blob/9b6de4e4367a465b7605eb931d0e4375df8f5ddd/crates/matrix-sdk-ui/src/unable_to_decrypt_hook.rs#L268-L283

bnjbvr commented 6 hours ago

For what it's worth: it was simple enough that we implemented it at the FFI layer, in the UTD hook trait impl:

https://github.com/matrix-org/matrix-rust-sdk/blob/02c7c2cdfc10a18d32c498f15d8ff40268108205/bindings/matrix-sdk-ffi/src/sync_service.rs#L171-L186

Might be fine to move it over to the SDK, if that's what you implied here, but probably lower priority.