Compare commits
13 Commits
letterbox-
...
letterbox-
| Author | SHA1 | Date | |
|---|---|---|---|
| dfa80f9046 | |||
| b8dfdabf8d | |||
| bbcf52b006 | |||
| f92c05cd28 | |||
| 885bbe0a8c | |||
| 8b1d111837 | |||
| 08abf31fa9 | |||
| fa99959508 | |||
| 0f6af0f475 | |||
| 4c486e9168 | |||
| 109d380ea7 | |||
| 4244fa0d82 | |||
| 4b15e71893 |
16
Cargo.lock
generated
16
Cargo.lock
generated
@@ -3034,7 +3034,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "letterbox-notmuch"
|
name = "letterbox-notmuch"
|
||||||
version = "0.17.10"
|
version = "0.17.17"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools",
|
"itertools",
|
||||||
"log",
|
"log",
|
||||||
@@ -3049,7 +3049,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "letterbox-procmail2notmuch"
|
name = "letterbox-procmail2notmuch"
|
||||||
version = "0.17.10"
|
version = "0.17.17"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -3062,7 +3062,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "letterbox-server"
|
name = "letterbox-server"
|
||||||
version = "0.17.10"
|
version = "0.17.17"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ammonia",
|
"ammonia",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@@ -3080,8 +3080,8 @@ dependencies = [
|
|||||||
"futures 0.3.31",
|
"futures 0.3.31",
|
||||||
"headers",
|
"headers",
|
||||||
"html-escape",
|
"html-escape",
|
||||||
"letterbox-notmuch 0.17.10",
|
"letterbox-notmuch 0.17.17",
|
||||||
"letterbox-shared 0.17.10",
|
"letterbox-shared 0.17.17",
|
||||||
"linkify",
|
"linkify",
|
||||||
"log",
|
"log",
|
||||||
"lol_html",
|
"lol_html",
|
||||||
@@ -3121,10 +3121,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "letterbox-shared"
|
name = "letterbox-shared"
|
||||||
version = "0.17.10"
|
version = "0.17.17"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"build-info",
|
"build-info",
|
||||||
"letterbox-notmuch 0.17.10",
|
"letterbox-notmuch 0.17.17",
|
||||||
"regex",
|
"regex",
|
||||||
"serde",
|
"serde",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
@@ -3134,7 +3134,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "letterbox-web"
|
name = "letterbox-web"
|
||||||
version = "0.17.10"
|
version = "0.17.17"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"build-info",
|
"build-info",
|
||||||
"build-info-build",
|
"build-info-build",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ authors = ["Bill Thiede <git@xinu.tv>"]
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "UNLICENSED"
|
license = "UNLICENSED"
|
||||||
publish = ["xinu"]
|
publish = ["xinu"]
|
||||||
version = "0.17.10"
|
version = "0.17.17"
|
||||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ css-inline = "0.14.4"
|
|||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
headers = "0.4.0"
|
headers = "0.4.0"
|
||||||
html-escape = "0.2.13"
|
html-escape = "0.2.13"
|
||||||
letterbox-notmuch = { path = "../notmuch", version = "0.17.10", registry = "xinu" }
|
letterbox-notmuch = { path = "../notmuch", version = "0.17.17", registry = "xinu" }
|
||||||
letterbox-shared = { path = "../shared", version = "0.17.10", registry = "xinu" }
|
letterbox-shared = { path = "../shared", version = "0.17.17", registry = "xinu" }
|
||||||
linkify = "0.10.0"
|
linkify = "0.10.0"
|
||||||
log = "0.4.27"
|
log = "0.4.27"
|
||||||
lol_html = "2.3.0"
|
lol_html = "2.3.0"
|
||||||
|
|||||||
@@ -200,15 +200,21 @@ async fn send_refresh_websocket_handler(
|
|||||||
None => Some(10),
|
None => Some(10),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(err) = label_unprocessed(&nm, &pool, false, limit, "tag:unprocessed").await {
|
let mut ids = None;
|
||||||
error!("Failed to label_unprocessed: {err:?}");
|
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
|
connection_tracker
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
.send_message_all(WebsocketMessage::RefreshMessages)
|
.send_message_all(WebsocketMessage::RefreshMessages)
|
||||||
.await;
|
.await;
|
||||||
"refresh triggered"
|
if let Some(ids) = ids {
|
||||||
|
format!("{ids:?}")
|
||||||
|
} else {
|
||||||
|
"refresh triggered".to_string()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn watch_new(
|
async fn watch_new(
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use log::{error, info, warn};
|
|||||||
use mailparse::{parse_content_type, parse_mail, MailHeader, MailHeaderMap, ParsedMail};
|
use mailparse::{parse_content_type, parse_mail, MailHeader, MailHeaderMap, ParsedMail};
|
||||||
use memmap::MmapOptions;
|
use memmap::MmapOptions;
|
||||||
use sqlx::{types::Json, PgPool};
|
use sqlx::{types::Json, PgPool};
|
||||||
use tracing::instrument;
|
use tracing::{info_span, instrument};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
compute_offset_limit,
|
compute_offset_limit,
|
||||||
@@ -946,7 +946,7 @@ pub async fn label_unprocessed(
|
|||||||
dryrun: bool,
|
dryrun: bool,
|
||||||
limit: Option<usize>,
|
limit: Option<usize>,
|
||||||
query: &str,
|
query: &str,
|
||||||
) -> Result<(), ServerError> {
|
) -> Result<Box<[String]>, ServerError> {
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
let ids = nm.message_ids(query)?;
|
let ids = nm.message_ids(query)?;
|
||||||
info!(
|
info!(
|
||||||
@@ -990,8 +990,9 @@ pub async fn label_unprocessed(
|
|||||||
// Only process the first file path is multiple files have the same id
|
// Only process the first file path is multiple files have the same id
|
||||||
let path = files.iter().next().unwrap();
|
let path = files.iter().next().unwrap();
|
||||||
let file = File::open(&path)?;
|
let file = File::open(&path)?;
|
||||||
|
info!("parsing {path}");
|
||||||
let mmap = unsafe { MmapOptions::new().map(&file)? };
|
let mmap = unsafe { MmapOptions::new().map(&file)? };
|
||||||
let m = parse_mail(&mmap)?;
|
let m = info_span!("parse_mail", path = path).in_scope(|| parse_mail(&mmap))?;
|
||||||
let (matched_rule, add_tags) = find_tags(&rules, &m.headers);
|
let (matched_rule, add_tags) = find_tags(&rules, &m.headers);
|
||||||
if matched_rule {
|
if matched_rule {
|
||||||
if dryrun {
|
if dryrun {
|
||||||
@@ -1028,11 +1029,6 @@ pub async fn label_unprocessed(
|
|||||||
.push(id.clone());
|
.push(id.clone());
|
||||||
}
|
}
|
||||||
//nm.tag_remove("unprocessed", &id)?;
|
//nm.tag_remove("unprocessed", &id)?;
|
||||||
let t = "unprocessed".to_string();
|
|
||||||
rm_mutations
|
|
||||||
.entry(t)
|
|
||||||
.or_insert_with(|| Vec::new())
|
|
||||||
.push(id.clone());
|
|
||||||
} else {
|
} else {
|
||||||
if add_tags.is_empty() {
|
if add_tags.is_empty() {
|
||||||
let t = "Grey".to_string();
|
let t = "Grey".to_string();
|
||||||
@@ -1041,26 +1037,39 @@ pub async fn label_unprocessed(
|
|||||||
.or_insert_with(|| Vec::new())
|
.or_insert_with(|| Vec::new())
|
||||||
.push(id.clone());
|
.push(id.clone());
|
||||||
}
|
}
|
||||||
|
//nm.tag_remove("inbox", &id)?;
|
||||||
|
let t = "inbox".to_string();
|
||||||
|
rm_mutations
|
||||||
|
.entry(t)
|
||||||
|
.or_insert_with(|| Vec::new())
|
||||||
|
.push(id.clone());
|
||||||
}
|
}
|
||||||
|
let t = "unprocessed".to_string();
|
||||||
|
rm_mutations
|
||||||
|
.entry(t)
|
||||||
|
.or_insert_with(|| Vec::new())
|
||||||
|
.push(id.clone());
|
||||||
}
|
}
|
||||||
println!("Adding {} distinct labels", add_mutations.len());
|
info!("Adding {} distinct labels", add_mutations.len());
|
||||||
for (tag, ids) in add_mutations.iter() {
|
for (tag, ids) in add_mutations.iter() {
|
||||||
println!(" {tag}: {}", ids.len());
|
info!(" {tag}: {}", ids.len());
|
||||||
if !dryrun {
|
if !dryrun {
|
||||||
let ids: Vec<_> = ids.iter().map(|s| s.as_str()).collect();
|
let ids: Vec<_> = ids.iter().map(|s| s.as_str()).collect();
|
||||||
nm.tags_add(tag, &ids)?;
|
info_span!("tags_add", tag = tag, count = ids.len())
|
||||||
|
.in_scope(|| nm.tags_add(tag, &ids))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("Removing {} distinct labels", rm_mutations.len());
|
info!("Removing {} distinct labels", rm_mutations.len());
|
||||||
for (tag, ids) in rm_mutations.iter() {
|
for (tag, ids) in rm_mutations.iter() {
|
||||||
println!(" {tag}: {}", ids.len());
|
info!(" {tag}: {}", ids.len());
|
||||||
if !dryrun {
|
if !dryrun {
|
||||||
let ids: Vec<_> = ids.iter().map(|s| s.as_str()).collect();
|
let ids: Vec<_> = ids.iter().map(|s| s.as_str()).collect();
|
||||||
nm.tags_remove(tag, &ids)?;
|
info_span!("tags_remove", tag = tag, count = ids.len())
|
||||||
|
.in_scope(|| nm.tags_remove(tag, &ids))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(ids.into())
|
||||||
}
|
}
|
||||||
fn find_tags<'a, 'b>(rules: &'a [Rule], headers: &'b [MailHeader]) -> (bool, HashSet<&'a str>) {
|
fn find_tags<'a, 'b>(rules: &'a [Rule], headers: &'b [MailHeader]) -> (bool, HashSet<&'a str>) {
|
||||||
let mut matched_rule = false;
|
let mut matched_rule = false;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ version.workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
build-info = "0.0.40"
|
build-info = "0.0.40"
|
||||||
letterbox-notmuch = { path = "../notmuch", version = "0.17.10", registry = "xinu" }
|
letterbox-notmuch = { path = "../notmuch", version = "0.17.17", registry = "xinu" }
|
||||||
regex = "1.11.1"
|
regex = "1.11.1"
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
sqlx = "0.8.5"
|
sqlx = "0.8.5"
|
||||||
|
|||||||
Reference in New Issue
Block a user