Upsert snoozes and mark snoozed messages as read

This commit is contained in:
Bill Thiede 2025-11-03 15:42:03 -08:00
parent 50a4bfcac7
commit a8129e4685
4 changed files with 17 additions and 6 deletions

4
Cargo.lock generated
View File

@ -5624,7 +5624,6 @@ dependencies = [
"sha2 0.10.9",
"smallvec 1.15.1",
"thiserror 2.0.17",
"time 0.3.44",
"tokio 1.48.0",
"tokio-stream",
"tracing",
@ -5708,7 +5707,6 @@ dependencies = [
"sqlx-core",
"stringprep",
"thiserror 2.0.17",
"time 0.3.44",
"tracing",
"whoami",
]
@ -5747,7 +5745,6 @@ dependencies = [
"sqlx-core",
"stringprep",
"thiserror 2.0.17",
"time 0.3.44",
"tracing",
"whoami",
]
@ -5773,7 +5770,6 @@ dependencies = [
"serde_urlencoded",
"sqlx-core",
"thiserror 2.0.17",
"time 0.3.44",
"tracing",
"url",
]

View File

@ -45,7 +45,7 @@ reqwest = { version = "0.12.15", features = ["blocking"] }
scraper = "0.24.0"
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
sqlx = { version = "0.8.5", features = ["postgres", "runtime-tokio", "time", "chrono"] }
sqlx = { version = "0.8.5", features = ["postgres", "runtime-tokio", "chrono"] }
tantivy = { version = "0.25.0", optional = true }
thiserror = "2.0.12"
tokio = "1.44.2"

View File

@ -1,6 +1,6 @@
-- Add up migration script here
CREATE TABLE IF NOT EXISTS snooze (
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
message_id text NOT NULL,
message_id text NOT NULL UNIQUE,
wake timestamptz NOT NULL
);

View File

@ -642,12 +642,27 @@ impl MutationRoot {
r#"
INSERT INTO snooze (message_id, wake)
VALUES ($1, $2)
ON CONFLICT (message_id) DO UPDATE
SET wake = $2
"#,
query,
wake_time
)
.execute(pool)
.await?;
let nm = ctx.data_unchecked::<Notmuch>();
let pool = ctx.data_unchecked::<PgPool>();
#[cfg(feature = "tantivy")]
let tantivy = ctx.data_unchecked::<TantivyConnection>();
let unread = false;
let query: Query = query.parse()?;
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?;
Ok(true)
}
/// Drop and recreate tantivy index. Warning this is slow