};
use serde::{Deserialize, Serialize};
use std::str::FromStr;
+use url::Url;
#[derive(Serialize, Deserialize, Debug)]
pub struct CreatePost {
return Err(APIError::err("site_ban").into());
}
+ if let Some(url) = data.url.as_ref() {
+ match Url::parse(url) {
+ Ok(_t) => (),
+ Err(_e) => return Err(APIError::err("invalid_url").into()),
+ }
+ }
+
// Fetch Iframely and pictrs cached image
let (iframely_title, iframely_description, iframely_html, pictrs_thumbnail) =
fetch_iframely_and_pictrs_data(&self.client, data.url.to_owned()).await;
"what_is": "What is",
"cake_day_title": "Cake day:",
"cake_day_info": "It's {{ creator_name }}'s cake day today!",
- "invalid_post_title": "Invalid post title"
+ "invalid_post_title": "Invalid post title",
+ "invalid_url": "Invalid URL."
}