diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index c3a25ec65..959cde2bb 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -717,7 +717,13 @@ async fn add_parts( // if a chat is protected, check additional properties if !chat_id.is_special() { let chat = Chat::load_from_db(context, *chat_id).await?; - if chat.is_protected() { + let new_status = match mime_parser.is_system_message { + SystemMessage::ChatProtectionEnabled => Some(ProtectionStatus::Protected), + SystemMessage::ChatProtectionDisabled => Some(ProtectionStatus::Unprotected), + _ => None, + }; + + if chat.is_protected() || new_status.is_some() { if let Err(err) = check_verified_properties(context, mime_parser, from_id as u32, to_ids).await { @@ -726,12 +732,16 @@ async fn add_parts( mime_parser.repl_msg_by_error(s); } else { // change chat protection only when verification check passes - if let Some(new_status) = match mime_parser.is_system_message { - SystemMessage::ChatProtectionEnabled => Some(ProtectionStatus::Protected), - SystemMessage::ChatProtectionDisabled => Some(ProtectionStatus::Unprotected), - _ => None, - } { - chat_id.inner_set_protection(context, new_status).await?; + if let Some(new_status) = new_status { + if let Err(e) = chat_id.inner_set_protection(context, new_status).await { + chat::add_info_msg( + context, + *chat_id, + format!("Cannot set protection: {}", e), + ) + .await; + return Ok(()); // do not return an error as this would result in retrying the message + } set_better_msg( mime_parser, context.stock_protection_msg(new_status, from_id).await,