Compare commits

...

3 Commits

Author SHA1 Message Date
e1681edda3 chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 1m1s
Continuous integration / Test Suite (push) Successful in 1m32s
Continuous integration / Trunk (push) Successful in 1m0s
Continuous integration / Rustfmt (push) Successful in 39s
Continuous integration / build (push) Successful in 1m41s
Continuous integration / Disallow unused dependencies (push) Successful in 2m12s
2025-11-05 21:12:09 -08:00
25ee8522ad cargo sqlx prepare 2025-11-05 21:12:08 -08:00
df356e8711 server: add label_unprocessed method, and implement wake 2025-11-05 21:11:26 -08:00
8 changed files with 96 additions and 14 deletions

18
Cargo.lock generated
View File

@ -3156,7 +3156,7 @@ dependencies = [
[[package]]
name = "letterbox-notmuch"
version = "0.17.48"
version = "0.17.49"
dependencies = [
"itertools",
"log",
@ -3171,7 +3171,7 @@ dependencies = [
[[package]]
name = "letterbox-procmail2notmuch"
version = "0.17.48"
version = "0.17.49"
dependencies = [
"anyhow",
"clap",
@ -3184,7 +3184,7 @@ dependencies = [
[[package]]
name = "letterbox-server"
version = "0.17.48"
version = "0.17.49"
dependencies = [
"ammonia",
"anyhow",
@ -3207,8 +3207,8 @@ dependencies = [
"html-escape",
"html2text",
"ical",
"letterbox-notmuch 0.17.48",
"letterbox-shared 0.17.48",
"letterbox-notmuch 0.17.49",
"letterbox-shared 0.17.49",
"linkify",
"lol_html",
"mailparse",
@ -3249,10 +3249,10 @@ dependencies = [
[[package]]
name = "letterbox-shared"
version = "0.17.48"
version = "0.17.49"
dependencies = [
"build-info 0.0.42",
"letterbox-notmuch 0.17.48",
"letterbox-notmuch 0.17.49",
"regex",
"serde",
"sqlx",
@ -3262,7 +3262,7 @@ dependencies = [
[[package]]
name = "letterbox-web"
version = "0.17.48"
version = "0.17.49"
dependencies = [
"build-info 0.0.42",
"build-info-build",
@ -3274,7 +3274,7 @@ dependencies = [
"graphql_client",
"human_format",
"itertools",
"letterbox-shared 0.17.48",
"letterbox-shared 0.17.49",
"log",
"seed",
"seed_hooks",

View File

@ -8,7 +8,7 @@ authors = ["Bill Thiede <git@xinu.tv>"]
edition = "2021"
license = "UNLICENSED"
publish = ["xinu"]
version = "0.17.48"
version = "0.17.49"
repository = "https://git.z.xinu.tv/wathiede/letterbox"
[profile.dev]

View File

@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM snooze WHERE id = $1",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int4"
]
},
"nullable": []
},
"hash": "77f79f981a9736d18ffd4b87d3aec34d6a048162154a3aba833370c58a860795"
}

View File

@ -0,0 +1,26 @@
{
"db_name": "PostgreSQL",
"query": "\nSELECT id, message_id\nFROM snooze\nWHERE wake < NOW();\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Int4"
},
{
"ordinal": 1,
"name": "message_id",
"type_info": "Text"
}
],
"parameters": {
"Left": []
},
"nullable": [
false,
false
]
},
"hash": "c8383663124a5cc5912b54553f18f7064d33087ebfdf3c0c1c43cbe6d3577084"
}

View File

@ -32,8 +32,8 @@ futures = "0.3.31"
headers = "0.4.0"
html-escape = "0.2.13"
ical = "0.11"
letterbox-notmuch = { path = "../notmuch", version = "0.17.48", registry = "xinu" }
letterbox-shared = { path = "../shared", version = "0.17.48", registry = "xinu" }
letterbox-notmuch = { path = "../notmuch", version = "0.17.49", registry = "xinu" }
letterbox-shared = { path = "../shared", version = "0.17.49", registry = "xinu" }
linkify = "0.10.0"
lol_html = "2.3.0"
mailparse = "0.16.1"

View File

@ -676,6 +676,18 @@ impl MutationRoot {
Ok(true)
}
#[instrument(skip_all, fields(rid=request_id()))]
async fn label_unprocessed<'ctx>(
&self,
ctx: &Context<'ctx>,
limit: Option<usize>,
) -> Result<bool, Error> {
let nm = ctx.data_unchecked::<Notmuch>();
let pool = ctx.data_unchecked::<PgPool>();
label_unprocessed(&nm, &pool, false, limit, "tag:unprocessed").await?;
Ok(true)
}
#[instrument(skip_all, fields(rid=request_id()))]
async fn refresh<'ctx>(&self, ctx: &Context<'ctx>) -> Result<bool, Error> {
let nm = ctx.data_unchecked::<Notmuch>();
@ -687,6 +699,9 @@ impl MutationRoot {
// Process email labels
label_unprocessed(&nm, &pool, false, Some(1000), "tag:unprocessed").await?;
// Look for snoozed messages and mark unread
wakeup(&nm, &pool).await?;
#[cfg(feature = "tantivy")]
{
let tantivy = ctx.data_unchecked::<TantivyConnection>();
@ -707,6 +722,33 @@ impl SubscriptionRoot {
pub type GraphqlSchema = Schema<QueryRoot, MutationRoot, SubscriptionRoot>;
#[instrument(name = "wakeup", skip_all)]
pub async fn wakeup(nm: &Notmuch, pool: &PgPool) -> Result<(), Error> {
for row in sqlx::query!(
r#"
SELECT id, message_id
FROM snooze
WHERE wake < NOW();
"#
)
.fetch_all(pool)
.await?
{
let query: Query = row.message_id.parse()?;
info!("need to wake {query}");
let unread = true;
newsreader::set_read_status(pool, &query, unread).await?;
#[cfg(feature = "tantivy")]
tantivy.reindex_thread(pool, &query).await?;
nm::set_read_status(nm, &query, unread).await?;
sqlx::query!("DELETE FROM snooze WHERE id = $1", row.id)
.execute(pool)
.await?;
}
Ok(())
}
#[instrument(skip_all, fields(query=query))]
pub async fn compute_catchup_ids(
nm: &Notmuch,

View File

@ -12,7 +12,7 @@ version.workspace = true
[dependencies]
build-info = "0.0.42"
letterbox-notmuch = { path = "../notmuch", version = "0.17.48", registry = "xinu" }
letterbox-notmuch = { path = "../notmuch", version = "0.17.49", registry = "xinu" }
regex = "1.11.1"
serde = { version = "1.0.219", features = ["derive"] }
sqlx = "0.8.5"

View File

@ -33,7 +33,7 @@ wasm-bindgen = "=0.2.100"
uuid = { version = "1.16.0", features = [
"js",
] } # direct dep to set js feature, prevents Rng issues
letterbox-shared = { path = "../shared/", version = "0.17.48", registry = "xinu" }
letterbox-shared = { path = "../shared/", version = "0.17.49", registry = "xinu" }
seed_hooks = { version = "0.4.1", registry = "xinu" }
strum_macros = "0.27.1"
gloo-console = "0.3.0"