refactor(imap): pass Session to add_all_recipients_as_contacts()

This commit is contained in:
link2xt
2024-02-28 22:51:07 +00:00
parent 85c9622675
commit 9e00e8627f

View File

@@ -756,13 +756,14 @@ impl Imap {
} }
self.prepare(context).await.context("could not connect")?; self.prepare(context).await.context("could not connect")?;
add_all_recipients_as_contacts(context, self, Config::ConfiguredSentboxFolder) let session = self.session.as_mut().context("No IMAP session")?;
add_all_recipients_as_contacts(context, session, Config::ConfiguredSentboxFolder)
.await .await
.context("failed to get recipients from the sentbox")?; .context("failed to get recipients from the sentbox")?;
add_all_recipients_as_contacts(context, self, Config::ConfiguredMvboxFolder) add_all_recipients_as_contacts(context, session, Config::ConfiguredMvboxFolder)
.await .await
.context("failed to get recipients from the movebox")?; .context("failed to get recipients from the movebox")?;
add_all_recipients_as_contacts(context, self, Config::ConfiguredInboxFolder) add_all_recipients_as_contacts(context, session, Config::ConfiguredInboxFolder)
.await .await
.context("failed to get recipients from the inbox")?; .context("failed to get recipients from the inbox")?;
@@ -2398,7 +2399,7 @@ impl std::fmt::Display for UidRange {
} }
async fn add_all_recipients_as_contacts( async fn add_all_recipients_as_contacts(
context: &Context, context: &Context,
imap: &mut Imap, session: &mut Session,
folder: Config, folder: Config,
) -> Result<()> { ) -> Result<()> {
let mailbox = if let Some(m) = context.get_config(folder).await? { let mailbox = if let Some(m) = context.get_config(folder).await? {
@@ -2410,7 +2411,6 @@ async fn add_all_recipients_as_contacts(
); );
return Ok(()); return Ok(());
}; };
let session = imap.session.as_mut().context("No IMAP session")?;
session session
.select_with_uidvalidity(context, &mailbox) .select_with_uidvalidity(context, &mailbox)
.await .await