Skip to content

Commit

Permalink
chore: emit info log when buffering, restoring, or clearing future me…
Browse files Browse the repository at this point in the history
…ssages

(cherry picked and adapted from commit 08b4563)
  • Loading branch information
SimonThormeyer committed Jan 27, 2025
1 parent c014c51 commit c74c432
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion crypto/src/mls/conversation/buffer_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! Feel free to delete all of this when the issue is fixed on the DS side !
use crate::context::CentralContext;
use crate::obfuscate::Obfuscated;
use crate::{
group_store::GroupStoreValue,
prelude::{
Expand Down Expand Up @@ -73,7 +74,6 @@ impl MlsConversation {
is_rejoin: bool,
) -> CryptoResult<Option<Vec<MlsBufferedConversationDecryptMessage>>> {
// using the macro produces a clippy warning
info!("restore_pending_messages");
let result = async move {
let keystore = backend.keystore();
let group_id = self.id().as_slice();
Expand Down Expand Up @@ -109,6 +109,8 @@ impl MlsConversation {
// luckily for us that's the exact same order as the [ContentType] enum
pending_messages.sort_by(|(a, _), (b, _)| a.cmp(b));

info!(group_id = Obfuscated::from(&self.id); "Attempting to restore {} buffered messages", pending_messages.len());

let mut decrypted_messages = Vec::with_capacity(pending_messages.len());
for (_, m) in pending_messages {
let parent_conversation = match &self.parent_id {
Expand Down
12 changes: 8 additions & 4 deletions crypto/src/mls/conversation/decrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ impl MlsConversation {
.restore_pending_messages(client, backend, callbacks, parent_conv, false)
.await?
{
info!(group_id = Obfuscated::from(&self.id); "Clearing all buffered messages for conversation");
backend.key_store().remove::<MlsPendingMessage, _>(self.id()).await?;
Some(pm)
} else {
Expand Down Expand Up @@ -442,10 +443,13 @@ impl CentralContext {
)
.await;

let decrypt_message = match decrypt_message {
Err(CryptoError::BufferedFutureMessage) => self.handle_future_message(id, message).await?,
_ => decrypt_message?,
};
if let Err(CryptoError::BufferedFutureMessage { message_epoch }) = decrypt_message {
self.handle_future_message(id, message).await?;
info!(group_id = Obfuscated::from(id); "Buffered future message from epoch {message_epoch}");
return decrypt_message;
}

let decrypt_message = decrypt_message?;

if !decrypt_message.is_active {
self.wipe_conversation(id).await?;
Expand Down

0 comments on commit c74c432

Please sign in to comment.