Add custom_details and custom_activity_details as first routes

how this works: we use find_by_host() to find the Host in question, the
defer to the existing function!

Caveat: Currently, we, in that function, we do another lookup DB lookup
for the Blog, even thou we already know it.
It might be wise, to have both of those another wrapper here?!
This commit is contained in:
Igor Galić
2019-05-27 17:55:09 +02:00
committed by Igor Galić
parent 0645f7e253
commit 468e663344
4 changed files with 53 additions and 9 deletions
+17
View File
@@ -195,6 +195,23 @@ impl Blog {
}
}
pub fn find_by_host(c: &PlumeRocket, host: Host) -> Result<Blog> {
let from_db = blogs::table
.filter(blogs::custom_domain.eq(host))
.limit(1)
.load::<Blog>(&*c.conn)?
.into_iter()
.next();
if let Some(from_db) = from_db {
Ok(from_db)
} else {
// we should never get here, because
// a) load::<Blog>()? should return early if it fails
// b) this function is only called after a Request::guard::<Host>()
Err(Error::NotFound)
}
}
fn fetch_from_webfinger(c: &PlumeRocket, acct: &str) -> Result<Blog> {
resolve_with_prefix(Prefix::Group, acct.to_owned(), true)?
.links