From ac280782b27b07e5282af03e329253503100ef99 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 7 Mar 2020 18:31:13 -0500 Subject: Iframely and pictshare backend mostly done. --- server/src/api/post.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'server/src/api/post.rs') diff --git a/server/src/api/post.rs b/server/src/api/post.rs index 00bf8e11..fb022589 100644 --- a/server/src/api/post.rs +++ b/server/src/api/post.rs @@ -110,6 +110,10 @@ impl Perform for Oper { return Err(APIError::err("site_ban").into()); } + // Fetch Iframely and Pictshare cached image + let (iframely_title, iframely_description, iframely_html, pictshare_thumbnail) = + fetch_iframely_and_pictshare_data(data.url.to_owned()); + let post_form = PostForm { name: data.name.to_owned(), url: data.url.to_owned(), @@ -122,6 +126,10 @@ impl Perform for Oper { locked: None, stickied: None, updated: None, + embed_title: iframely_title, + embed_description: iframely_description, + embed_html: iframely_html, + thumbnail_url: pictshare_thumbnail, }; let inserted_post = match Post::create(&conn, &post_form) { @@ -353,6 +361,10 @@ impl Perform for Oper { return Err(APIError::err("site_ban").into()); } + // Fetch Iframely and Pictshare cached image + let (iframely_title, iframely_description, iframely_html, pictshare_thumbnail) = + fetch_iframely_and_pictshare_data(data.url.to_owned()); + let post_form = PostForm { name: data.name.to_owned(), url: data.url.to_owned(), @@ -365,6 +377,10 @@ impl Perform for Oper { locked: data.locked.to_owned(), stickied: data.stickied.to_owned(), updated: Some(naive_now()), + embed_title: iframely_title, + embed_description: iframely_description, + embed_html: iframely_html, + thumbnail_url: pictshare_thumbnail, }; let _updated_post = match Post::update(&conn, data.edit_id, &post_form) { -- cgit v1.2.3