diff --git a/Cargo.lock b/Cargo.lock index 1ab9542..54cc82f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -963,7 +963,7 @@ dependencies = [ "rocket_i18n 0.1.1 (git+https://github.com/BaptisteGelez/rocket_i18n?rev=5b4225d5bed5769482dc926a7e6d6b79f1217be6)", "rpassword 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", - "webfinger 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "webfinger 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1010,7 +1010,7 @@ dependencies = [ "serde_derive 1.0.43 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webfinger 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "webfinger 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1190,7 +1190,7 @@ dependencies = [ "cc 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "untrusted 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1817,7 +1817,7 @@ dependencies = [ [[package]] name = "untrusted" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1865,7 +1865,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "webfinger" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "reqwest 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2118,7 +2118,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unidecode 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "402bb19d8e03f1d1a7450e2bd613980869438e0666331be3e073089124aa1adc" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -"checksum untrusted 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70afa43c8c5d23a53a3c39ec9b56232c5badc19f6bb5ad529c1d6448a7241365" +"checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" "checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7" "checksum utf-8 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1262dfab4c30d5cb7c07026be00ee343a6cf5027fdc0104a9160f354e5db75c" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" @@ -2126,7 +2126,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum vcpkg 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7ed0f6789c8a85ca41bbc1c9d175422116a9869bd1cf31bb08e1493ecce60380" "checksum version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6b772017e347561807c1aa192438c5fd74242a670a6cffacc40f2defd1dc069d" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum webfinger 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "27a4e6d1de7050af8beb026c02bcef5340ec1f3af6d4a02248b7990908baa3ff" +"checksum webfinger 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a3e10c73859f818558bbed7fc9bf69a939ebdfc86cba637c9e7eda4606088eae" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/Cargo.toml b/Cargo.toml index a904a2d..50e3c67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ gettext-rs = "0.4" heck = "0.3.0" rpassword = "2.0" serde_json = "1.0" -webfinger = "0.1" +webfinger = "0.2" [dependencies.diesel] features = ["postgres", "r2d2", "chrono"] diff --git a/plume-models/Cargo.toml b/plume-models/Cargo.toml index 3cc99fd..a6d44f4 100644 --- a/plume-models/Cargo.toml +++ b/plume-models/Cargo.toml @@ -15,7 +15,7 @@ serde = "*" serde_derive = "1.0" serde_json = "1.0" url = "1.7" -webfinger = "0.1" +webfinger = "0.2" [dependencies.chrono] features = ["serde"] diff --git a/plume-models/src/blogs.rs b/plume-models/src/blogs.rs index 0e63f6d..842eaff 100644 --- a/plume-models/src/blogs.rs +++ b/plume-models/src/blogs.rs @@ -16,7 +16,7 @@ use openssl::{ }; use webfinger::*; -use BASE_URL; +use {BASE_URL, USE_HTTPS}; use plume_common::activity_pub::{ ApSignature, ActivityStream, Id, IntoId, PublicKey, inbox::WithInbox, @@ -97,7 +97,7 @@ impl Blog { } fn fetch_from_webfinger(conn: &PgConnection, acct: String) -> Option { - 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| Blog::fetch_from_url(conn, l.href)), Err(details) => { println!("{:?}", details); diff --git a/plume-models/src/lib.rs b/plume-models/src/lib.rs index 3caaaea..8c35e42 100644 --- a/plume-models/src/lib.rs +++ b/plume-models/src/lib.rs @@ -88,6 +88,8 @@ lazy_static! { pub static ref DB_URL: String = env::var("DB_URL") .unwrap_or(format!("postgres://plume:plume@localhost/{}", env::var("DB_NAME").unwrap_or(String::from("plume")))); + + pub static ref USE_HTTPS: bool = env::var("USE_HTTPS").map(|val| val == "1").unwrap_or(true); } pub mod blog_authors; diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index 6a107c5..ce51610 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -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 { - 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 + } } }