server: return ids processed from send_refresh_websocket_handler
This commit is contained in:
parent
885bbe0a8c
commit
f92c05cd28
@ -200,15 +200,21 @@ async fn send_refresh_websocket_handler(
|
||||
None => Some(10),
|
||||
};
|
||||
|
||||
if let Err(err) = label_unprocessed(&nm, &pool, false, limit, "tag:unprocessed").await {
|
||||
error!("Failed to label_unprocessed: {err:?}");
|
||||
let mut ids = None;
|
||||
match label_unprocessed(&nm, &pool, false, limit, "tag:unprocessed").await {
|
||||
Ok(i) => ids = Some(i),
|
||||
Err(err) => error!("Failed to label_unprocessed: {err:?}"),
|
||||
};
|
||||
connection_tracker
|
||||
.lock()
|
||||
.await
|
||||
.send_message_all(WebsocketMessage::RefreshMessages)
|
||||
.await;
|
||||
"refresh triggered"
|
||||
if let Some(ids) = ids {
|
||||
format!("{ids:?}")
|
||||
} else {
|
||||
"refresh triggered".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
async fn watch_new(
|
||||
|
||||
@ -946,7 +946,7 @@ pub async fn label_unprocessed(
|
||||
dryrun: bool,
|
||||
limit: Option<usize>,
|
||||
query: &str,
|
||||
) -> Result<(), ServerError> {
|
||||
) -> Result<Box<[String]>, ServerError> {
|
||||
use futures::StreamExt;
|
||||
let ids = nm.message_ids(query)?;
|
||||
info!(
|
||||
@ -990,7 +990,6 @@ pub async fn label_unprocessed(
|
||||
// Only process the first file path is multiple files have the same id
|
||||
let path = files.iter().next().unwrap();
|
||||
let file = File::open(&path)?;
|
||||
info!("mmaping {path}");
|
||||
let mmap = unsafe { MmapOptions::new().map(&file)? };
|
||||
let m = parse_mail(&mmap)?;
|
||||
let (matched_rule, add_tags) = find_tags(&rules, &m.headers);
|
||||
@ -1067,7 +1066,7 @@ pub async fn label_unprocessed(
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(ids.into())
|
||||
}
|
||||
fn find_tags<'a, 'b>(rules: &'a [Rule], headers: &'b [MailHeader]) -> (bool, HashSet<&'a str>) {
|
||||
let mut matched_rule = false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user