summaryrefslogtreecommitdiffstats
path: root/server/src/api/post.rs
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-03-07 18:31:13 -0500
committerDessalines <tyhou13@gmx.com>2020-03-07 18:31:13 -0500
commitac280782b27b07e5282af03e329253503100ef99 (patch)
tree85cb2195686814650986d6d9c96eb6bf9d121c1b /server/src/api/post.rs
parent496c4e523c95ffad4b2749896f6c22409a2b3c3f (diff)
Iframely and pictshare backend mostly done.
Diffstat (limited to 'server/src/api/post.rs')
-rw-r--r--server/src/api/post.rs16
1 files changed, 16 insertions, 0 deletions
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) {