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