Use the creation date from ActivityPub when fetching remote articles

This commit is contained in:
Bat 2018-07-27 00:29:21 +02:00
parent 0314629d99
commit 812b76b0de
2 changed files with 5 additions and 2 deletions

View File

@ -45,6 +45,7 @@ pub struct NewPost {
pub content: SafeString,
pub published: bool,
pub license: String,
pub creation_date: Option<NaiveDateTime>,
pub ap_url: String
}
@ -248,7 +249,8 @@ impl FromActivity<Article, PgConnection> 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() {

View File

@ -142,7 +142,8 @@ fn create(blog_name: String, data: LenientForm<NewPostForm>, 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 {