diff --git a/plume-models/src/blogs.rs b/plume-models/src/blogs.rs index 5baf85b5..728f4dec 100644 --- a/plume-models/src/blogs.rs +++ b/plume-models/src/blogs.rs @@ -8,8 +8,9 @@ use openssl::{ sign::{Signer, Verifier}, }; use rocket::{ + http::RawStr, outcome::IntoOutcome, - request::{self, FromRequest, Request}, + request::{self, FromFormValue, FromRequest, Request}, }; use serde_json; use url::Url; @@ -71,6 +72,15 @@ impl<'a, 'r> FromRequest<'a, 'r> for Host { } } +impl<'v> FromFormValue<'v> for Host { + type Error = &'v RawStr; + + fn from_form_value(form_value: &'v RawStr) -> std::result::Result { + let val = String::from_form_value(form_value)?; + Ok(Host::new(&val)) + } +} + #[derive(Queryable, Identifiable, Clone, AsChangeset)] #[changeset_options(treat_none_as_null = "true")] pub struct Blog { diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index 6cbcd460..e58c859b 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -333,6 +333,7 @@ pub struct EditForm { pub summary: String, pub icon: Option, pub banner: Option, + pub custom_domain: Option, } #[get("/~//edit")] @@ -359,6 +360,7 @@ pub fn edit(name: String, rockets: PlumeRocket) -> Result { summary: blog.summary.clone(), icon: blog.icon_id, banner: blog.banner_id, + custom_domain: blog.custom_domain.clone(), }, ValidationErrors::default() )))