From 34579974c38810d2007995050409628bc3a14c9c Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Mon, 8 Jun 2020 08:29:58 +0300 Subject: [PATCH] Don't make ad-hoc groups when message cannot be decrypted This fixes the test added in the parent commit. --- src/dc_receive_imf.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 00804c6cb..311b507de 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -1293,6 +1293,24 @@ async fn create_or_lookup_adhoc_group( return Ok((ChatId::new(0), Blocked::Not)); } + if mime_parser.decrypting_failed { + // Do not create a new ad-hoc group if the message cannot be + // decrypted. + // + // The subject may be encrypted and contain a placeholder such + // as "...". Besides that, it is possible that the message was + // sent to a valid, yet unknown group, which was rejected + // because Chat-Group-Name, which is in the encrypted part, + // was not found. Generating a new ID in this case would + // result in creation of a twin group with a different group + // ID. + warn!( + context, + "not creating ad-hoc group for message that cannot be decrypted" + ); + return Ok((ChatId::new(0), Blocked::Not)); + } + // we do not check if the message is a reply to another group, this may result in // chats with unclear member list. instead we create a new group in the following lines ...