@@ -1284,6 +1284,7 @@ impl Session {
12841284 if request_uids. is_empty ( ) {
12851285 return Ok ( ( ) ) ;
12861286 }
1287+ let is_chatmail = self . is_chatmail ( ) ;
12871288
12881289 for ( request_uids, set) in build_sequence_sets ( & request_uids) ? {
12891290 info ! ( context, "Starting UID FETCH of message set \" {}\" ." , set) ;
@@ -1381,6 +1382,29 @@ impl Session {
13811382 "Passing message UID {} to receive_imf()." , request_uid
13821383 ) ;
13831384 let res = receive_imf_inner ( context, rfc724_mid, body, is_seen) . await ;
1385+
1386+ // If the message is not needed anymore on the server, mark it for deletion:
1387+ info ! (
1388+ context,
1389+ "dbg Marking for deletion?: bcc_self={}, is_chatmail={}" ,
1390+ context. get_config_bool( Config :: BccSelf ) . await ?,
1391+ is_chatmail
1392+ ) ;
1393+ if !context. get_config_bool ( Config :: BccSelf ) . await ? && is_chatmail {
1394+ info ! ( context, "dbg Marking {rfc724_mid} for deletion" ) ;
1395+ context
1396+ . sql
1397+ . execute (
1398+ & format ! ( "UPDATE imap SET target='' WHERE rfc724_mid=?" ) ,
1399+ ( rfc724_mid, ) ,
1400+ )
1401+ . await ?;
1402+ context. scheduler . interrupt_inbox ( ) . await ;
1403+ } else {
1404+ info ! ( context, "dbg NOT marking {rfc724_mid} for deletion" ) ;
1405+ }
1406+
1407+ // If there was an error receiving the message, show a device message:
13841408 let received_msg = match res {
13851409 Err ( err) => {
13861410 warn ! ( context, "receive_imf error: {err:#}." ) ;
0 commit comments