list custom_domains

thanks a lot to @fdb-hiroshima and @BaptisteGelez for helping with the
code.
This commit is contained in:
Igor Galić
2019-08-14 23:51:05 +02:00
committed by Igor Galić
parent 65ae51b7e5
commit 351c01f71c
2 changed files with 13 additions and 1 deletions
+10 -1
View File
@@ -81,7 +81,7 @@ pub struct NewBlog {
pub summary_html: SafeString,
pub icon_id: Option<i32>,
pub banner_id: Option<i32>,
pub custom_domain: Option<String>,
pub custom_domain: Option<Host>,
}
const BLOG_PREFIX: &str = "~";
@@ -311,6 +311,15 @@ impl Blog {
.map(|_| ())
.map_err(Error::from)
}
pub fn list_custom_domains(conn: &Connection) -> Result<Vec<String>> {
blogs::table
.filter(blogs::custom_domain.is_not_null())
.select(blogs::custom_domain)
.load::<Option<String>>(conn)
.map_err(Error::from)
.map(|res| res.into_iter().map(|s| s.unwrap()).collect::<Vec<_>>())
}
}
impl<'a, 'r> FromRequest<'a, 'r> for Host {