(
context: &Context,
mime_parser: &MimeMessage,
parent_message: &Option<Message>,
rfc724_mid: &str,
from_id: ContactId,
)
| 1153 | |
| 1154 | #[expect(clippy::arithmetic_side_effects)] |
| 1155 | async fn decide_chat_assignment( |
| 1156 | context: &Context, |
| 1157 | mime_parser: &MimeMessage, |
| 1158 | parent_message: &Option<Message>, |
| 1159 | rfc724_mid: &str, |
| 1160 | from_id: ContactId, |
| 1161 | ) -> Result<ChatAssignment> { |
| 1162 | let mut should_trash = if !mime_parser.mdn_reports.is_empty() { |
| 1163 | info!(context, "Message is an MDN (TRASH)."); |
| 1164 | true |
| 1165 | } else if mime_parser.delivery_report.is_some() { |
| 1166 | info!(context, "Message is a DSN (TRASH)."); |
| 1167 | markseen_on_imap_table(context, rfc724_mid).await.ok(); |
| 1168 | true |
| 1169 | } else if mime_parser.get_header(HeaderDef::ChatEdit).is_some() |
| 1170 | || mime_parser.get_header(HeaderDef::ChatDelete).is_some() |
| 1171 | || mime_parser.get_header(HeaderDef::IrohNodeAddr).is_some() |
| 1172 | || mime_parser.sync_items.is_some() |
| 1173 | { |
| 1174 | info!(context, "Chat edit/delete/iroh/sync message (TRASH)."); |
| 1175 | true |
| 1176 | } else if mime_parser.is_system_message == SystemMessage::CallAccepted |
| 1177 | || mime_parser.is_system_message == SystemMessage::CallEnded |
| 1178 | { |
| 1179 | info!(context, "Call state changed (TRASH)."); |
| 1180 | true |
| 1181 | } else if let Some(ref decryption_error) = mime_parser.decryption_error |
| 1182 | && !mime_parser.incoming |
| 1183 | { |
| 1184 | // Outgoing undecryptable message. |
| 1185 | let last_time = context |
| 1186 | .get_config_i64(Config::LastCantDecryptOutgoingMsgs) |
| 1187 | .await?; |
| 1188 | let now = tools::time(); |
| 1189 | let update_config = if last_time.saturating_add(24 * 60 * 60) <= now { |
| 1190 | let txt = format!( |
| 1191 | "⚠️ It seems you are using Delta Chat on multiple devices that cannot decrypt each other's outgoing messages. To fix this, on the older device use \"Settings / Add Second Device\" and follow the instructions. (Error: {decryption_error}, {rfc724_mid})." |
| 1192 | ); |
| 1193 | let mut msg = Message::new_text(txt.to_string()); |
| 1194 | chat::add_device_msg(context, None, Some(&mut msg)) |
| 1195 | .await |
| 1196 | .log_err(context) |
| 1197 | .ok(); |
| 1198 | true |
| 1199 | } else { |
| 1200 | last_time > now |
| 1201 | }; |
| 1202 | if update_config { |
| 1203 | context |
| 1204 | .set_config_internal(Config::LastCantDecryptOutgoingMsgs, Some(&now.to_string())) |
| 1205 | .await?; |
| 1206 | } |
| 1207 | info!(context, "Outgoing undecryptable message (TRASH)."); |
| 1208 | true |
| 1209 | } else if mime_parser |
| 1210 | .get_header(HeaderDef::XMozillaDraftInfo) |
| 1211 | .is_some() |
| 1212 | { |
no test coverage detected