mirror of
https://github.com/chatmail/core.git
synced 2026-05-09 01:46:30 +03:00
refactor(imap): move fetch_many_msgs() into Session
This commit is contained in:
@@ -194,7 +194,10 @@ impl Imap {
|
|||||||
|
|
||||||
let mut uid_message_ids: BTreeMap<u32, String> = BTreeMap::new();
|
let mut uid_message_ids: BTreeMap<u32, String> = BTreeMap::new();
|
||||||
uid_message_ids.insert(uid, rfc724_mid);
|
uid_message_ids.insert(uid, rfc724_mid);
|
||||||
let (last_uid, _received) = match self
|
let Some(session) = self.session.as_mut() else {
|
||||||
|
return ImapActionResult::Failed;
|
||||||
|
};
|
||||||
|
let (last_uid, _received) = match session
|
||||||
.fetch_many_msgs(
|
.fetch_many_msgs(
|
||||||
context,
|
context,
|
||||||
folder,
|
folder,
|
||||||
|
|||||||
10
src/imap.rs
10
src/imap.rs
@@ -683,6 +683,9 @@ impl Imap {
|
|||||||
for (uid, fp) in uids_fetch {
|
for (uid, fp) in uids_fetch {
|
||||||
if fp != fetch_partially {
|
if fp != fetch_partially {
|
||||||
let (largest_uid_fetched_in_batch, received_msgs_in_batch) = self
|
let (largest_uid_fetched_in_batch, received_msgs_in_batch) = self
|
||||||
|
.session
|
||||||
|
.as_mut()
|
||||||
|
.context("No IMAP session")?
|
||||||
.fetch_many_msgs(
|
.fetch_many_msgs(
|
||||||
context,
|
context,
|
||||||
folder,
|
folder,
|
||||||
@@ -1222,9 +1225,7 @@ impl Session {
|
|||||||
}
|
}
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Imap {
|
|
||||||
/// Fetches a list of messages by server UID.
|
/// Fetches a list of messages by server UID.
|
||||||
///
|
///
|
||||||
/// Returns the last UID fetched successfully and the info about each downloaded message.
|
/// Returns the last UID fetched successfully and the info about each downloaded message.
|
||||||
@@ -1248,7 +1249,6 @@ impl Imap {
|
|||||||
return Ok((last_uid, received_msgs));
|
return Ok((last_uid, received_msgs));
|
||||||
}
|
}
|
||||||
|
|
||||||
let session = self.session.as_mut().context("no IMAP session")?;
|
|
||||||
for (request_uids, set) in build_sequence_sets(&request_uids)? {
|
for (request_uids, set) in build_sequence_sets(&request_uids)? {
|
||||||
info!(
|
info!(
|
||||||
context,
|
context,
|
||||||
@@ -1256,7 +1256,7 @@ impl Imap {
|
|||||||
if fetch_partially { "partial" } else { "full" },
|
if fetch_partially { "partial" } else { "full" },
|
||||||
set
|
set
|
||||||
);
|
);
|
||||||
let mut fetch_responses = session
|
let mut fetch_responses = self
|
||||||
.uid_fetch(
|
.uid_fetch(
|
||||||
&set,
|
&set,
|
||||||
if fetch_partially {
|
if fetch_partially {
|
||||||
@@ -1415,9 +1415,7 @@ impl Imap {
|
|||||||
|
|
||||||
Ok((last_uid, received_msgs))
|
Ok((last_uid, received_msgs))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Session {
|
|
||||||
/// Retrieves server metadata if it is supported.
|
/// Retrieves server metadata if it is supported.
|
||||||
///
|
///
|
||||||
/// We get [`/shared/comment`](https://www.rfc-editor.org/rfc/rfc5464#section-6.2.1)
|
/// We get [`/shared/comment`](https://www.rfc-editor.org/rfc/rfc5464#section-6.2.1)
|
||||||
|
|||||||
Reference in New Issue
Block a user