From a6c372421ce8e7f67cecc19684459cc6263a4184 Mon Sep 17 00:00:00 2001 From: Siddharth Doshi Date: Thu, 2 Oct 2025 16:45:47 +0200 Subject: [PATCH 1/2] support creation timestamps for bookmarks --- crates/karakeep-client/src/lib.rs | 10 ++++++---- crates/sync/src/plugin/github_stars.rs | 1 + crates/sync/src/plugin/hn_upvotes.rs | 1 + crates/sync/src/plugin/pinboard.rs | 1 + crates/sync/src/plugin/reddit_saves.rs | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/karakeep-client/src/lib.rs b/crates/karakeep-client/src/lib.rs index cd83bd3..e7d8059 100644 --- a/crates/karakeep-client/src/lib.rs +++ b/crates/karakeep-client/src/lib.rs @@ -8,6 +8,7 @@ pub struct KarakeepClient { pub struct BookmarkCreate { pub title: String, pub url: String, + pub created_at: Option, } impl KarakeepClient { @@ -25,12 +26,13 @@ impl KarakeepClient { } } - pub async fn create_bookmark(&self, title: &str, url: &str) -> anyhow::Result { + pub async fn create_bookmark(&self, bookmark: &BookmarkCreate) -> anyhow::Result { let api_url = format!("{}/api/v1/bookmarks", self.url); let params = serde_json::json!({ "type": "link", - "title": title, - "url": url, + "title": bookmark.title, + "url": bookmark.url, + "createdAt": bookmark.created_at, }); let resp = self @@ -183,7 +185,7 @@ impl KarakeepClient { // If it doesn't exist, create it if to_create { tracing::info!("creating bookmark: {} - {}", &bookmark.title, &bookmark.url); - bookmark_id = self.create_bookmark(&bookmark.title, &bookmark.url).await?; + bookmark_id = self.create_bookmark(bookmark).await?; } else { bookmark_id = exists.unwrap(); } diff --git a/crates/sync/src/plugin/github_stars.rs b/crates/sync/src/plugin/github_stars.rs index 1d69c29..25c3043 100644 --- a/crates/sync/src/plugin/github_stars.rs +++ b/crates/sync/src/plugin/github_stars.rs @@ -74,6 +74,7 @@ impl super::Plugin for GithubStars { .map(|item| BookmarkCreate { url: item["html_url"].as_str().unwrap_or("").to_string(), title: item["full_name"].as_str().unwrap_or("").to_string(), + created_at: None, }) .collect(); diff --git a/crates/sync/src/plugin/hn_upvotes.rs b/crates/sync/src/plugin/hn_upvotes.rs index 5461d44..40d2b8f 100644 --- a/crates/sync/src/plugin/hn_upvotes.rs +++ b/crates/sync/src/plugin/hn_upvotes.rs @@ -37,6 +37,7 @@ impl super::Plugin for HNUpvoted { .map(|post| BookmarkCreate { title: post.title, url: post.url, + created_at: None, }) .collect::>() }); diff --git a/crates/sync/src/plugin/pinboard.rs b/crates/sync/src/plugin/pinboard.rs index 657a19c..71187ae 100644 --- a/crates/sync/src/plugin/pinboard.rs +++ b/crates/sync/src/plugin/pinboard.rs @@ -57,6 +57,7 @@ impl super::Plugin for PinboardBookmarks { .map(|post| BookmarkCreate { url: post.href, title: post.description, + created_at: None, }) .collect(); diff --git a/crates/sync/src/plugin/reddit_saves.rs b/crates/sync/src/plugin/reddit_saves.rs index 1e85513..ab86d47 100644 --- a/crates/sync/src/plugin/reddit_saves.rs +++ b/crates/sync/src/plugin/reddit_saves.rs @@ -69,6 +69,7 @@ impl super::Plugin for RedditSaves { .map(|post| BookmarkCreate { title: post.title, url: post.url, + created_at: None, }) .collect::>(); From 7f86124399dfeabc26b0bc42c7d37acbf434258e Mon Sep 17 00:00:00 2001 From: Siddharth Doshi Date: Thu, 2 Oct 2025 16:54:41 +0200 Subject: [PATCH 2/2] send timestamps when creating bookmarks --- crates/sync/src/plugin/github_stars.rs | 1 + crates/sync/src/plugin/hn_upvotes.rs | 1 + crates/sync/src/plugin/pinboard.rs | 2 +- crates/sync/src/plugin/reddit_saves.rs | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/sync/src/plugin/github_stars.rs b/crates/sync/src/plugin/github_stars.rs index 25c3043..d9fb67f 100644 --- a/crates/sync/src/plugin/github_stars.rs +++ b/crates/sync/src/plugin/github_stars.rs @@ -74,6 +74,7 @@ impl super::Plugin for GithubStars { .map(|item| BookmarkCreate { url: item["html_url"].as_str().unwrap_or("").to_string(), title: item["full_name"].as_str().unwrap_or("").to_string(), + // GitHub does not provide timestamp for when the repo was starred created_at: None, }) .collect(); diff --git a/crates/sync/src/plugin/hn_upvotes.rs b/crates/sync/src/plugin/hn_upvotes.rs index 40d2b8f..aa9808d 100644 --- a/crates/sync/src/plugin/hn_upvotes.rs +++ b/crates/sync/src/plugin/hn_upvotes.rs @@ -37,6 +37,7 @@ impl super::Plugin for HNUpvoted { .map(|post| BookmarkCreate { title: post.title, url: post.url, + // HN does not provide timestamp for when the post was upvoted created_at: None, }) .collect::>() diff --git a/crates/sync/src/plugin/pinboard.rs b/crates/sync/src/plugin/pinboard.rs index 71187ae..ffdb47a 100644 --- a/crates/sync/src/plugin/pinboard.rs +++ b/crates/sync/src/plugin/pinboard.rs @@ -57,7 +57,7 @@ impl super::Plugin for PinboardBookmarks { .map(|post| BookmarkCreate { url: post.href, title: post.description, - created_at: None, + created_at: Some(post.time), }) .collect(); diff --git a/crates/sync/src/plugin/reddit_saves.rs b/crates/sync/src/plugin/reddit_saves.rs index ab86d47..347571c 100644 --- a/crates/sync/src/plugin/reddit_saves.rs +++ b/crates/sync/src/plugin/reddit_saves.rs @@ -69,6 +69,7 @@ impl super::Plugin for RedditSaves { .map(|post| BookmarkCreate { title: post.title, url: post.url, + // Reddt does not provide timestamp for when the post was saved created_at: None, }) .collect::>();