mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
refactor(imap): require watch_folder for fake_idle()
This commit is contained in:
@@ -101,7 +101,7 @@ impl Imap {
|
|||||||
pub(crate) async fn fake_idle(
|
pub(crate) async fn fake_idle(
|
||||||
&mut self,
|
&mut self,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
watch_folder: Option<String>,
|
watch_folder: String,
|
||||||
folder_meaning: FolderMeaning,
|
folder_meaning: FolderMeaning,
|
||||||
) {
|
) {
|
||||||
// Idle using polling. This is also needed if we're not yet configured -
|
// Idle using polling. This is also needed if we're not yet configured -
|
||||||
@@ -110,13 +110,6 @@ impl Imap {
|
|||||||
let fake_idle_start_time = tools::Time::now();
|
let fake_idle_start_time = tools::Time::now();
|
||||||
|
|
||||||
// Do not poll, just wait for an interrupt when no folder is passed in.
|
// Do not poll, just wait for an interrupt when no folder is passed in.
|
||||||
let watch_folder = if let Some(watch_folder) = watch_folder {
|
|
||||||
watch_folder
|
|
||||||
} else {
|
|
||||||
info!(context, "IMAP-fake-IDLE: no folder, waiting for interrupt");
|
|
||||||
self.idle_interrupt_receiver.recv().await.ok();
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
info!(context, "IMAP-fake-IDLEing folder={:?}", watch_folder);
|
info!(context, "IMAP-fake-IDLEing folder={:?}", watch_folder);
|
||||||
|
|
||||||
const TIMEOUT_INIT_MS: u64 = 60_000;
|
const TIMEOUT_INIT_MS: u64 = 60_000;
|
||||||
|
|||||||
@@ -541,9 +541,7 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder_meaning: Folder
|
|||||||
ctx,
|
ctx,
|
||||||
"Cannot watch {folder_meaning}, ensure_configured_folders() failed: {:#}", err,
|
"Cannot watch {folder_meaning}, ensure_configured_folders() failed: {:#}", err,
|
||||||
);
|
);
|
||||||
connection
|
connection.idle_interrupt_receiver.recv().await.ok();
|
||||||
.fake_idle(ctx, None, FolderMeaning::Unknown)
|
|
||||||
.await;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let (folder_config, watch_folder) = match convert_folder_meaning(ctx, folder_meaning).await {
|
let (folder_config, watch_folder) = match convert_folder_meaning(ctx, folder_meaning).await {
|
||||||
@@ -554,9 +552,7 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder_meaning: Folder
|
|||||||
// but watching Sent folder is enabled.
|
// but watching Sent folder is enabled.
|
||||||
warn!(ctx, "Error converting IMAP Folder name: {:?}", error);
|
warn!(ctx, "Error converting IMAP Folder name: {:?}", error);
|
||||||
connection.connectivity.set_not_configured(ctx).await;
|
connection.connectivity.set_not_configured(ctx).await;
|
||||||
connection
|
connection.idle_interrupt_receiver.recv().await.ok();
|
||||||
.fake_idle(ctx, None, FolderMeaning::Unknown)
|
|
||||||
.await;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -657,7 +653,7 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder_meaning: Folder
|
|||||||
let Some(session) = connection.session.take() else {
|
let Some(session) = connection.session.take() else {
|
||||||
warn!(ctx, "No IMAP session, going to fake idle.");
|
warn!(ctx, "No IMAP session, going to fake idle.");
|
||||||
connection
|
connection
|
||||||
.fake_idle(ctx, Some(watch_folder), folder_meaning)
|
.fake_idle(ctx, watch_folder, folder_meaning)
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@@ -668,7 +664,7 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder_meaning: Folder
|
|||||||
"IMAP session does not support IDLE, going to fake idle."
|
"IMAP session does not support IDLE, going to fake idle."
|
||||||
);
|
);
|
||||||
connection
|
connection
|
||||||
.fake_idle(ctx, Some(watch_folder), folder_meaning)
|
.fake_idle(ctx, watch_folder, folder_meaning)
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -682,7 +678,7 @@ async fn fetch_idle(ctx: &Context, connection: &mut Imap, folder_meaning: Folder
|
|||||||
{
|
{
|
||||||
info!(ctx, "IMAP IDLE is disabled, going to fake idle.");
|
info!(ctx, "IMAP IDLE is disabled, going to fake idle.");
|
||||||
connection
|
connection
|
||||||
.fake_idle(ctx, Some(watch_folder), folder_meaning)
|
.fake_idle(ctx, watch_folder, folder_meaning)
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user