diff --git a/Cargo.lock b/Cargo.lock index 0ca6230..6b7b3e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", ] diff --git a/server/Cargo.toml b/server/Cargo.toml index 41de25f..05e4c1d 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -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" diff --git a/server/migrations/20250630023836_snooze.up.sql b/server/migrations/20250630023836_snooze.up.sql index 07837e7..91e8c24 100644 --- a/server/migrations/20250630023836_snooze.up.sql +++ b/server/migrations/20250630023836_snooze.up.sql @@ -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 ); diff --git a/server/src/graphql.rs b/server/src/graphql.rs index 3ff5a3e..6cb34b3 100644 --- a/server/src/graphql.rs +++ b/server/src/graphql.rs @@ -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::(); + let pool = ctx.data_unchecked::(); + #[cfg(feature = "tantivy")] + let tantivy = ctx.data_unchecked::(); + + 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