Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions crates/karakeep-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub struct KarakeepClient {
pub struct BookmarkCreate {
pub title: String,
pub url: String,
pub created_at: Option<String>,
}

impl KarakeepClient {
Expand All @@ -25,12 +26,13 @@ impl KarakeepClient {
}
}

pub async fn create_bookmark(&self, title: &str, url: &str) -> anyhow::Result<String> {
pub async fn create_bookmark(&self, bookmark: &BookmarkCreate) -> anyhow::Result<String> {
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
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions crates/sync/src/plugin/github_stars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ 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();

Expand Down
2 changes: 2 additions & 0 deletions crates/sync/src/plugin/hn_upvotes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ 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::<Vec<_>>()
});
Expand Down
1 change: 1 addition & 0 deletions crates/sync/src/plugin/pinboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl super::Plugin for PinboardBookmarks {
.map(|post| BookmarkCreate {
url: post.href,
title: post.description,
created_at: Some(post.time),
})
.collect();

Expand Down
2 changes: 2 additions & 0 deletions crates/sync/src/plugin/reddit_saves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ 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::<Vec<_>>();

Expand Down