summaryrefslogtreecommitdiffstats
path: root/server/src/api/post.rs
diff options
context:
space:
mode:
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) {