MCPcopy Create free account
hub / github.com/chatmail/core / decide_chat_assignment

Function decide_chat_assignment

src/receive_imf.rs:1155–1409  ·  view source on GitHub ↗
(
    context: &Context,
    mime_parser: &MimeMessage,
    parent_message: &Option<Message>,
    rfc724_mid: &str,
    from_id: ContactId,
)

Source from the content-addressed store, hash-verified

1153
1154#[expect(clippy::arithmetic_side_effects)]
1155async 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 {

Callers 1

receive_imf_innerFunction · 0.85

Calls 15

markseen_on_imap_tableFunction · 0.85
timeFunction · 0.85
add_device_msgFunction · 0.85
msg_is_downloaded_forFunction · 0.85
rfc724_mid_exists_exFunction · 0.85
addr_cmpFunction · 0.85
lookup_chat_by_replyFunction · 0.85
get_config_i64Method · 0.80
log_errMethod · 0.80
set_config_internalMethod · 0.80
executeMethod · 0.80
countMethod · 0.80

Tested by

no test coverage detected