From 812b76b0dec30ec1252adf83bfb28f868d90b136 Mon Sep 17 00:00:00 2001 From: Bat Date: Fri, 27 Jul 2018 00:29:21 +0200 Subject: [PATCH] Use the creation date from ActivityPub when fetching remote articles --- plume-models/src/posts.rs | 4 +++- src/routes/posts.rs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index 16014e62..7ed756f1 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -45,6 +45,7 @@ pub struct NewPost { pub content: SafeString, pub published: bool, pub license: String, + pub creation_date: Option, pub ap_url: String } @@ -248,7 +249,8 @@ impl FromActivity for Post { published: true, license: String::from("CC-0"), // TODO // FIXME: This is wrong: with this logic, we may use the display URL as the AP ID. We need two different fields - ap_url: article.object_props.url_string().unwrap_or(article.object_props.id_string().expect("Post::from_activity: url + id error")) + ap_url: article.object_props.url_string().unwrap_or(article.object_props.id_string().expect("Post::from_activity: url + id error")), + creation_date: Some(article.object_props.published_utctime().expect("Post::from_activity: published error").naive_utc()) }); for author in authors.into_iter() { diff --git a/src/routes/posts.rs b/src/routes/posts.rs index 43bff378..24e44706 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -142,7 +142,8 @@ fn create(blog_name: String, data: LenientForm, user: User, conn: D content: SafeString::new(&content), published: true, license: form.license.to_string(), - ap_url: "".to_string() + ap_url: "".to_string(), + creation_date: None }); let post = post.update_ap_url(&*conn); PostAuthor::insert(&*conn, NewPostAuthor {