refactor: flatten GENERATED_PREFIX check in receive_imf_inner

This commit is contained in:
link2xt
2023-09-25 09:30:36 +00:00
parent a1345f2542
commit d0ee21e6dc

View File

@@ -113,8 +113,11 @@ pub(crate) async fn receive_imf_inner(
{ {
Err(err) => { Err(err) => {
warn!(context, "receive_imf: can't parse MIME: {err:#}."); warn!(context, "receive_imf: can't parse MIME: {err:#}.");
let msg_ids; if rfc724_mid.starts_with(GENERATED_PREFIX) {
if !rfc724_mid.starts_with(GENERATED_PREFIX) { // We don't have an rfc724_mid, there's no point in adding a trash entry
return Ok(None);
}
let row_id = context let row_id = context
.sql .sql
.execute( .execute(
@@ -122,11 +125,7 @@ pub(crate) async fn receive_imf_inner(
(rfc724_mid, DC_CHAT_ID_TRASH), (rfc724_mid, DC_CHAT_ID_TRASH),
) )
.await?; .await?;
msg_ids = vec![MsgId::new(u32::try_from(row_id)?)]; let msg_ids = vec![MsgId::new(u32::try_from(row_id)?)];
} else {
return Ok(None);
// We don't have an rfc724_mid, there's no point in adding a trash entry
}
return Ok(Some(ReceivedMsg { return Ok(Some(ReceivedMsg {
chat_id: DC_CHAT_ID_TRASH, chat_id: DC_CHAT_ID_TRASH,