mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
refator(imap): move sync_seen_flags() to Session
This commit is contained in:
18
src/imap.rs
18
src/imap.rs
@@ -1104,17 +1104,10 @@ impl Session {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Imap {
|
||||
/// Synchronizes `\Seen` flags using `CONDSTORE` extension.
|
||||
pub(crate) async fn sync_seen_flags(&mut self, context: &Context, folder: &str) -> Result<()> {
|
||||
let session = self
|
||||
.session
|
||||
.as_mut()
|
||||
.with_context(|| format!("No IMAP connection established, folder: {folder}"))?;
|
||||
|
||||
if !session.can_condstore() {
|
||||
if !self.can_condstore() {
|
||||
info!(
|
||||
context,
|
||||
"Server does not support CONDSTORE, skipping flag synchronization."
|
||||
@@ -1122,12 +1115,11 @@ impl Imap {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
session
|
||||
.select_folder(context, Some(folder))
|
||||
self.select_folder(context, Some(folder))
|
||||
.await
|
||||
.context("failed to select folder")?;
|
||||
|
||||
let mailbox = session
|
||||
let mailbox = self
|
||||
.selected_mailbox
|
||||
.as_ref()
|
||||
.with_context(|| format!("No mailbox selected, folder: {folder}"))?;
|
||||
@@ -1149,7 +1141,7 @@ impl Imap {
|
||||
let mut highest_modseq = get_modseq(context, folder)
|
||||
.await
|
||||
.with_context(|| format!("failed to get MODSEQ for folder {folder}"))?;
|
||||
let mut list = session
|
||||
let mut list = self
|
||||
.uid_fetch("1:*", format!("(FLAGS) (CHANGEDSINCE {highest_modseq})"))
|
||||
.await
|
||||
.context("failed to fetch flags")?;
|
||||
@@ -1195,7 +1187,9 @@ impl Imap {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Imap {
|
||||
/// Gets the from, to and bcc addresses from all existing outgoing emails.
|
||||
pub async fn get_all_recipients(&mut self, context: &Context) -> Result<Vec<SingleInfo>> {
|
||||
let session = self
|
||||
|
||||
@@ -638,12 +638,16 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder_meaning: Folder
|
||||
}
|
||||
|
||||
// Synchronize Seen flags.
|
||||
connection
|
||||
.sync_seen_flags(ctx, &watch_folder)
|
||||
.await
|
||||
.context("sync_seen_flags")
|
||||
.log_err(ctx)
|
||||
.ok();
|
||||
if let Some(session) = connection.session.as_mut() {
|
||||
session
|
||||
.sync_seen_flags(ctx, &watch_folder)
|
||||
.await
|
||||
.context("sync_seen_flags")
|
||||
.log_err(ctx)
|
||||
.ok();
|
||||
} else {
|
||||
warn!(ctx, "No IMAP session, skipping flag synchronization.");
|
||||
}
|
||||
|
||||
connection.connectivity.set_idle(ctx).await;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user