diff options
author | Dessalines <tyhou13@gmx.com> | 2020-03-07 18:31:13 -0500 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-03-07 18:31:13 -0500 |
commit | ac280782b27b07e5282af03e329253503100ef99 (patch) | |
tree | 85cb2195686814650986d6d9c96eb6bf9d121c1b /server/src/api | |
parent | 496c4e523c95ffad4b2749896f6c22409a2b3c3f (diff) |
Iframely and pictshare backend mostly done.
Diffstat (limited to 'server/src/api')
-rw-r--r-- | server/src/api/mod.rs | 3 | ||||
-rw-r--r-- | server/src/api/post.rs | 16 | ||||
-rw-r--r-- | server/src/api/user.rs | 4 |
3 files changed, 22 insertions, 1 deletions
diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs index 155c706a..e4fdfee6 100644 --- a/server/src/api/mod.rs +++ b/server/src/api/mod.rs @@ -18,7 +18,8 @@ use crate::db::user_mention_view::*; use crate::db::user_view::*; use crate::db::*; use crate::{ - extract_usernames, naive_from_unix, naive_now, remove_slurs, slur_check, slurs_vec_to_str, + extract_usernames, fetch_iframely_and_pictshare_data, naive_from_unix, naive_now, remove_slurs, + slur_check, slurs_vec_to_str, }; use diesel::PgConnection; use failure::Error; 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<PostResponse> for Oper<CreatePost> { 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<PostResponse> for Oper<CreatePost> { 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<PostResponse> for Oper<EditPost> { 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<PostResponse> for Oper<EditPost> { 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) { diff --git a/server/src/api/user.rs b/server/src/api/user.rs index 1d332b90..f7313895 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -883,6 +883,10 @@ impl Perform<LoginResponse> for Oper<DeleteAccount> { locked: None, stickied: None, updated: Some(naive_now()), + embed_title: None, + embed_description: None, + embed_html: None, + thumbnail_url: None, }; let _updated_post = match Post::update(&conn, post.id, &post_form) { |