refactor(imap): move fetch_many_msgs() into Session

This commit is contained in:
link2xt
2024-02-28 22:48:23 +00:00
parent 30432d8fa5
commit 85c9622675
2 changed files with 8 additions and 7 deletions

View File

@@ -194,7 +194,10 @@ impl Imap {
let mut uid_message_ids: BTreeMap<u32, String> = BTreeMap::new();
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(
context,
folder,

View File

@@ -683,6 +683,9 @@ impl Imap {
for (uid, fp) in uids_fetch {
if fp != fetch_partially {
let (largest_uid_fetched_in_batch, received_msgs_in_batch) = self
.session
.as_mut()
.context("No IMAP session")?
.fetch_many_msgs(
context,
folder,
@@ -1222,9 +1225,7 @@ impl Session {
}
Ok(result)
}
}
impl Imap {
/// Fetches a list of messages by server UID.
///
/// 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));
}
let session = self.session.as_mut().context("no IMAP session")?;
for (request_uids, set) in build_sequence_sets(&request_uids)? {
info!(
context,
@@ -1256,7 +1256,7 @@ impl Imap {
if fetch_partially { "partial" } else { "full" },
set
);
let mut fetch_responses = session
let mut fetch_responses = self
.uid_fetch(
&set,
if fetch_partially {
@@ -1415,9 +1415,7 @@ impl Imap {
Ok((last_uid, received_msgs))
}
}
impl Session {
/// Retrieves server metadata if it is supported.
///
/// We get [`/shared/comment`](https://www.rfc-editor.org/rfc/rfc5464#section-6.2.1)