mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
refactor(imap): move fetch_metadata() to Session
This commit is contained in:
@@ -1415,15 +1415,16 @@ 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)
|
||||||
/// and [`/shared/admin`](https://www.rfc-editor.org/rfc/rfc5464#section-6.2.2)
|
/// and [`/shared/admin`](https://www.rfc-editor.org/rfc/rfc5464#section-6.2.2)
|
||||||
/// metadata.
|
/// metadata.
|
||||||
pub(crate) async fn fetch_metadata(&mut self, context: &Context) -> Result<()> {
|
pub(crate) async fn fetch_metadata(&mut self, context: &Context) -> Result<()> {
|
||||||
let session = self.session.as_mut().context("no session")?;
|
if !self.can_metadata() {
|
||||||
if !session.can_metadata() {
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1442,7 +1443,7 @@ impl Imap {
|
|||||||
|
|
||||||
let mailbox = "";
|
let mailbox = "";
|
||||||
let options = "";
|
let options = "";
|
||||||
let metadata = session
|
let metadata = self
|
||||||
.get_metadata(mailbox, options, "(/shared/comment /shared/admin)")
|
.get_metadata(mailbox, options, "(/shared/comment /shared/admin)")
|
||||||
.await?;
|
.await?;
|
||||||
for m in metadata {
|
for m in metadata {
|
||||||
|
|||||||
@@ -473,8 +473,10 @@ async fn inbox_loop(
|
|||||||
warn!(ctx, "Failed to download messages: {:#}", err);
|
warn!(ctx, "Failed to download messages: {:#}", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = connection.fetch_metadata(&ctx).await {
|
if let Some(session) = connection.session.as_mut() {
|
||||||
warn!(ctx, "Failed to fetch metadata: {err:#}.");
|
if let Err(err) = session.fetch_metadata(&ctx).await {
|
||||||
|
warn!(ctx, "Failed to fetch metadata: {err:#}.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch_idle(&ctx, &mut connection, FolderMeaning::Inbox).await;
|
fetch_idle(&ctx, &mut connection, FolderMeaning::Inbox).await;
|
||||||
|
|||||||
Reference in New Issue
Block a user