Update the WebFinger crate
Fixes an issue with some Mastodon accounts
This commit is contained in:
parent
ab4af10ce5
commit
5583029b07
|
@ -1004,7 +1004,7 @@ dependencies = [
|
||||||
"serde_json 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"validator 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"validator 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"validator_derive 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"validator_derive 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"webfinger 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"webfinger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"workerpool 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"workerpool 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1052,7 +1052,7 @@ dependencies = [
|
||||||
"serde_derive 1.0.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"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)",
|
"url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"webfinger 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"webfinger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2003,7 +2003,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webfinger"
|
name = "webfinger"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"reqwest 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"reqwest 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2286,7 +2286,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 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 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 void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||||
"checksum webfinger 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a3e10c73859f818558bbed7fc9bf69a939ebdfc86cba637c9e7eda4606088eae"
|
"checksum webfinger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e34ffa5f00fedd30b71718a02b973df00a66e8059ad041bc597b455b22a2aba2"
|
||||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
"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 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"
|
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||||
|
|
|
@ -15,7 +15,7 @@ serde_derive = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
validator = "0.7"
|
validator = "0.7"
|
||||||
validator_derive = "0.7"
|
validator_derive = "0.7"
|
||||||
webfinger = "0.2"
|
webfinger = "0.3"
|
||||||
workerpool = "1.1"
|
workerpool = "1.1"
|
||||||
|
|
||||||
[dependencies.diesel]
|
[dependencies.diesel]
|
||||||
|
|
|
@ -4,10 +4,7 @@ use reqwest::{
|
||||||
mime::Mime,
|
mime::Mime,
|
||||||
header::{Accept, Date, Headers, UserAgent, qitem}
|
header::{Accept, Date, Headers, UserAgent, qitem}
|
||||||
};
|
};
|
||||||
use std::{
|
use std::time::SystemTime;
|
||||||
str::FromStr,
|
|
||||||
time::SystemTime
|
|
||||||
};
|
|
||||||
|
|
||||||
use activity_pub::ap_accept_header;
|
use activity_pub::ap_accept_header;
|
||||||
use activity_pub::sign::Signer;
|
use activity_pub::sign::Signer;
|
||||||
|
|
|
@ -15,7 +15,7 @@ serde = "*"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
url = "1.7"
|
url = "1.7"
|
||||||
webfinger = "0.2"
|
webfinger = "0.3"
|
||||||
|
|
||||||
[dependencies.chrono]
|
[dependencies.chrono]
|
||||||
features = ["serde"]
|
features = ["serde"]
|
||||||
|
|
|
@ -108,7 +108,7 @@ impl Blog {
|
||||||
|
|
||||||
fn fetch_from_webfinger(conn: &PgConnection, acct: String) -> Option<Blog> {
|
fn fetch_from_webfinger(conn: &PgConnection, acct: String) -> Option<Blog> {
|
||||||
match resolve(acct.clone(), *USE_HTTPS) {
|
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)),
|
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.expect("No href for AP WF link"))),
|
||||||
Err(details) => {
|
Err(details) => {
|
||||||
println!("{:?}", details);
|
println!("{:?}", details);
|
||||||
None
|
None
|
||||||
|
@ -221,17 +221,20 @@ impl Blog {
|
||||||
Link {
|
Link {
|
||||||
rel: String::from("http://webfinger.net/rel/profile-page"),
|
rel: String::from("http://webfinger.net/rel/profile-page"),
|
||||||
mime_type: None,
|
mime_type: None,
|
||||||
href: self.ap_url.clone()
|
href: Some(self.ap_url.clone()),
|
||||||
|
template: None
|
||||||
},
|
},
|
||||||
Link {
|
Link {
|
||||||
rel: String::from("http://schemas.google.com/g/2010#updates-from"),
|
rel: String::from("http://schemas.google.com/g/2010#updates-from"),
|
||||||
mime_type: Some(String::from("application/atom+xml")),
|
mime_type: Some(String::from("application/atom+xml")),
|
||||||
href: self.get_instance(conn).compute_box(BLOG_PREFIX, self.actor_id.clone(), "feed.atom")
|
href: Some(self.get_instance(conn).compute_box(BLOG_PREFIX, self.actor_id.clone(), "feed.atom")),
|
||||||
|
template: None
|
||||||
},
|
},
|
||||||
Link {
|
Link {
|
||||||
rel: String::from("self"),
|
rel: String::from("self"),
|
||||||
mime_type: Some(String::from("application/activity+json")),
|
mime_type: Some(String::from("application/activity+json")),
|
||||||
href: self.ap_url.clone()
|
href: Some(self.ap_url.clone()),
|
||||||
|
template: None
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,9 +144,9 @@ impl User {
|
||||||
|
|
||||||
fn fetch_from_webfinger(conn: &PgConnection, acct: String) -> Option<User> {
|
fn fetch_from_webfinger(conn: &PgConnection, acct: String) -> Option<User> {
|
||||||
match resolve(acct.clone(), *USE_HTTPS) {
|
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)),
|
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.expect("No href for AP WF link"))),
|
||||||
Err(details) => {
|
Err(details) => {
|
||||||
println!("{:?}", details);
|
println!("WF Error: {:?}", details);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ impl User {
|
||||||
Some(User::from_activity(conn, json, Url::parse(url.as_ref()).unwrap().host_str().unwrap().to_string()))
|
Some(User::from_activity(conn, json, Url::parse(url.as_ref()).unwrap().host_str().unwrap().to_string()))
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("{:?}", e);
|
println!("User fetch error: {:?}", e);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,17 +386,20 @@ impl User {
|
||||||
Link {
|
Link {
|
||||||
rel: String::from("http://webfinger.net/rel/profile-page"),
|
rel: String::from("http://webfinger.net/rel/profile-page"),
|
||||||
mime_type: None,
|
mime_type: None,
|
||||||
href: self.ap_url.clone()
|
href: Some(self.ap_url.clone()),
|
||||||
|
template: None
|
||||||
},
|
},
|
||||||
Link {
|
Link {
|
||||||
rel: String::from("http://schemas.google.com/g/2010#updates-from"),
|
rel: String::from("http://schemas.google.com/g/2010#updates-from"),
|
||||||
mime_type: Some(String::from("application/atom+xml")),
|
mime_type: Some(String::from("application/atom+xml")),
|
||||||
href: self.get_instance(conn).compute_box(USER_PREFIX, self.username.clone(), "feed.atom")
|
href: Some(self.get_instance(conn).compute_box(USER_PREFIX, self.username.clone(), "feed.atom")),
|
||||||
|
template: None
|
||||||
},
|
},
|
||||||
Link {
|
Link {
|
||||||
rel: String::from("self"),
|
rel: String::from("self"),
|
||||||
mime_type: Some(String::from("application/activity+json")),
|
mime_type: Some(String::from("application/activity+json")),
|
||||||
href: self.ap_url.clone()
|
href: Some(self.ap_url.clone()),
|
||||||
|
template: None
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue