Centralize configuration and add some new config (#494)

Ideally, if someone could review the idea in [this comment](https://github.com/Plume-org/Plume/issues/273#issuecomment-474982184), I'd like to add the implementation to this pr too
This commit is contained in:
fdb-hiroshima
2019-03-21 10:30:33 +01:00
committed by Baptiste Gelez
parent b945d1f602
commit 65bb50e88f
12 changed files with 117 additions and 89 deletions
+3 -3
View File
@@ -26,7 +26,7 @@ use safe_string::SafeString;
use schema::blogs;
use search::Searcher;
use users::User;
use {Connection, Error, Result, BASE_URL, USE_HTTPS};
use {Connection, Error, Result, CONFIG};
pub type CustomGroup = CustomObject<ApSignature, Group>;
@@ -142,7 +142,7 @@ impl Blog {
}
fn fetch_from_webfinger(conn: &Connection, acct: &str) -> Result<Blog> {
resolve(acct.to_owned(), *USE_HTTPS)?
resolve(acct.to_owned(), true)?
.links
.into_iter()
.find(|l| l.mime_type == Some(String::from("application/activity+json")))
@@ -288,7 +288,7 @@ impl Blog {
Blog::find_by_ap_url(conn, url).or_else(|_| {
// The requested blog was not in the DB
// We try to fetch it if it is remote
if Url::parse(url)?.host_str()? != BASE_URL.as_str() {
if Url::parse(url)?.host_str()? != CONFIG.base_url.as_str() {
Blog::fetch_from_url(conn, url)
} else {
Err(Error::NotFound)