From: Felix Ableitner Date: Thu, 19 Mar 2020 16:27:13 +0000 (+0100) Subject: Populate post data from apub X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/%22%7Burl%7D/%7BlocalRss%7D?a=commitdiff_plain;h=672798e71145116591c4b3ce1f5c14d001d4be0c;p=lemmy.git Populate post data from apub --- diff --git a/server/src/apub/puller.rs b/server/src/apub/puller.rs index 1a9c2a1c..bdcb9ab2 100644 --- a/server/src/apub/puller.rs +++ b/server/src/apub/puller.rs @@ -66,7 +66,6 @@ where } // TODO: should cache responses here when we are in production // TODO: this function should return a future - // TODO: in production mode, fail if protocol is not https let x: Response = reqwest::get(uri)?.json()?; Ok(x) } @@ -82,18 +81,32 @@ pub fn get_remote_community_posts(identifier: &str) -> Result().unwrap(); - // TODO: need to populate this PostView { id: -1, name: page.object_props.get_name_xsd_string().unwrap().to_string(), - url: None, - body: None, + url: page + .object_props + .get_url_xsd_any_uri() + .map(|u| u.to_string()), + body: page + .object_props + .get_content_xsd_string() + .map(|c| c.to_string()), creator_id: -1, community_id: -1, removed: false, locked: false, - published: naive_now(), - updated: None, + published: page + .object_props + .get_published() + .unwrap() + .as_ref() + .naive_local() + .to_owned(), + updated: page + .object_props + .get_updated() + .map(|u| u.as_ref().to_owned().naive_local()), deleted: false, nsfw: false, stickied: false, @@ -206,7 +219,8 @@ pub fn get_all_communities() -> Result, Error> { Ok(communities_list) } -/// If community is on local instance, don't include the @instance part +/// If community is on local instance, don't include the @instance part. This is only for displaying +/// to the user and should never be used otherwise. pub fn format_community_name(name: &str, instance: &str) -> String { if instance == Settings::get().hostname { format!("!{}", name)