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!())?; .imap_ctx(&arguments.tag, trc::location!())?;
if ids.is_empty() { if ids.is_empty() {
return Err(trc::ImapEvent::Error trc::event!(
.into_err() Imap(if is_move {
.details("No messages were found.") trc::ImapEvent::Move
.id(arguments.tag)); } 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. // 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. // Map copied JMAP Ids to IMAP UIDs in the destination folder.
if copied_ids.is_empty() { if copied_ids.is_empty() {
return Err(if response.rtype != ResponseType::Ok { return if response.rtype != ResponseType::Ok {
trc::ImapEvent::Error Err(trc::ImapEvent::Error
.into_err() .into_err()
.details(response.message) .details(response.message)
.ctx_opt(trc::Key::Code, response.code) .ctx_opt(trc::Key::Code, response.code)
.id(arguments.tag))
} else { } else {
trc::ImapEvent::Error.into_err().details(if is_move { 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." "No messages were moved."
} else { } else {
"No messages were copied." "No messages were copied."
}) })
} .with_tag(arguments.tag)
.id(arguments.tag)); .into_bytes(),
)
.await
};
} }
// Prepare response // Prepare response