aboutsummaryrefslogtreecommitdiff
path: root/src/imap/mailbox_view.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/imap/mailbox_view.rs')
-rw-r--r--src/imap/mailbox_view.rs39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs
index 7434512..861d27c 100644
--- a/src/imap/mailbox_view.rs
+++ b/src/imap/mailbox_view.rs
@@ -600,6 +600,37 @@ impl MailboxView {
Ok((to_state.uidvalidity, ret))
}
+ pub async fn r#move(
+ &mut self,
+ sequence_set: &SequenceSet,
+ to: Arc<Mailbox>,
+ is_uid_copy: &bool,
+ ) -> Result<(ImapUidvalidity, Vec<(ImapUid, ImapUid)>, Vec<Body<'static>>)> {
+ let mails = self.get_mail_ids(sequence_set, *is_uid_copy)?;
+
+ let mut new_uuids = vec![];
+ for mi in mails.iter() {
+ let copy_action = to.copy_from(&self.mailbox, mi.uuid).await?;
+ new_uuids.push(copy_action);
+ self.mailbox.delete(mi.uuid).await?
+ }
+
+ let mut ret = vec![];
+ let to_state = to.current_uid_index().await;
+ for (mi, new_uuid) in mails.iter().zip(new_uuids.iter()) {
+ let dest_uid = to_state
+ .table
+ .get(new_uuid)
+ .ok_or(anyhow!("moved mail not in destination mailbox"))?
+ .0;
+ ret.push((mi.uid, dest_uid));
+ }
+
+ let update = self.update().await?;
+
+ Ok((to_state.uidvalidity, ret, update))
+ }
+
/// Looks up state changes in the mailbox and produces a set of IMAP
/// responses describing the new state.
pub async fn fetch<'b>(
@@ -1242,7 +1273,11 @@ fn get_message_section<'a>(
part.as_ref().map(|p| p.0.as_ref()).unwrap_or(&[]),
|part_msg| {
let mut ret = vec![];
- for f in &part_msg.mime().kv {
+ let mime = match &part_msg {
+ AnyPart::Msg(msg) => msg.child.mime(),
+ other => other.mime(),
+ };
+ for f in mime.kv.iter() {
let (k, v) = match f {
header::Field::Good(header::Kv2(k, v)) => (k, v),
_ => continue,
@@ -1272,7 +1307,7 @@ fn get_message_section<'a>(
let bytes = match &part {
AnyPart::Txt(p) => p.mime.fields.raw,
AnyPart::Bin(p) => p.mime.fields.raw,
- AnyPart::Msg(p) => p.mime.fields.raw,
+ AnyPart::Msg(p) => p.child.mime().raw,
AnyPart::Mult(p) => p.mime.fields.raw,
};
Ok(bytes.to_vec().into())