Introduce an environment variable to disable HTTPS, and use it when fetching WebFinger resources

You can now use USE_HTTPS=0 when debugging the federation locally.
This commit is contained in:
Bat
2018-06-26 16:16:59 +02:00
parent 5bbfd9d1e9
commit f805ec1d53
6 changed files with 19 additions and 14 deletions
+6 -3
View File
@@ -30,7 +30,7 @@ use serde_json;
use url::Url;
use webfinger::*;
use BASE_URL;
use {BASE_URL, USE_HTTPS};
use db_conn::DbConn;
use blogs::Blog;
use blog_authors::BlogAuthor;
@@ -143,7 +143,7 @@ impl User {
}
fn fetch_from_webfinger(conn: &PgConnection, acct: String) -> Option<User> {
match resolve(acct.clone()) {
match resolve(acct.clone(), *USE_HTTPS) {
Ok(wf) => wf.links.into_iter().find(|l| l.mime_type == Some(String::from("application/activity+json"))).and_then(|l| User::fetch_from_url(conn, l.href)),
Err(details) => {
println!("{:?}", details);
@@ -165,7 +165,10 @@ impl User {
json.custom_props = ap_sign; // without this workaround, publicKey is not correctly deserialized
Some(User::from_activity(conn, json, Url::parse(url.as_ref()).unwrap().host_str().unwrap().to_string()))
},
Err(_) => None
Err(e) => {
println!("{:?}", e);
None
}
}
}