Return OK when moving/copying non-existent messages via IMAP (#670)

This commit is contained in:
mdecimus 2025-07-27 09:09:13 +02:00
parent 20a3868938
commit 9cc91d2787

View file

@ -123,10 +123,32 @@ impl<T: SessionStream> SessionData<T> {
.imap_ctx(&arguments.tag, trc::location!())?;
if ids.is_empty() {
return Err(trc::ImapEvent::Error
.into_err()
.details("No messages were found.")
.id(arguments.tag));
trc::event!(
Imap(if is_move {
trc::ImapEvent::Move
} else {
trc::ImapEvent::Copy
}),
SpanId = self.session_id,
Source = src_mailbox.id.account_id,
Details = trc::Value::None,
Uid = trc::Value::None,
AccountId = dest_mailbox.account_id,
MailboxId = dest_mailbox.mailbox_id,
Elapsed = op_start.elapsed()
);
return self
.write_bytes(
StatusResponse::ok(if is_move {
"No messages were moved."
} else {
"No messages were copied."
})
.with_tag(arguments.tag)
.into_bytes(),
)
.await;
}
// Verify that the user can delete messages from the source mailbox.
@ -426,19 +448,39 @@ impl<T: SessionStream> SessionData<T> {
// Map copied JMAP Ids to IMAP UIDs in the destination folder.
if copied_ids.is_empty() {
return Err(if response.rtype != ResponseType::Ok {
trc::ImapEvent::Error
return if response.rtype != ResponseType::Ok {
Err(trc::ImapEvent::Error
.into_err()
.details(response.message)
.ctx_opt(trc::Key::Code, response.code)
.id(arguments.tag))
} else {
trc::ImapEvent::Error.into_err().details(if is_move {
"No messages were moved."
} else {
"No messages were copied."
})
}
.id(arguments.tag));
trc::event!(
Imap(if is_move {
trc::ImapEvent::Move
} else {
trc::ImapEvent::Copy
}),
SpanId = self.session_id,
Source = src_mailbox.id.account_id,
Details = trc::Value::None,
Uid = trc::Value::None,
AccountId = dest_mailbox.account_id,
MailboxId = dest_mailbox.mailbox_id,
Elapsed = op_start.elapsed()
);
self.write_bytes(
StatusResponse::ok(if is_move {
"No messages were moved."
} else {
"No messages were copied."
})
.with_tag(arguments.tag)
.into_bytes(),
)
.await
};
}
// Prepare response