Add support for remote interact (#519)
Add support for remote interaction ([this thing](https://eldritch.cafe/users/Barmaid/remote_follow) in mastodon) - [x] create the endpoint dispatching remote interactions to local pages - [x] add this endpoint to web-finger - [x] propose remote interaction when following and not connected - [x] propose remote interaction when liking/sharing and not connected - [x] propose remote interaction when commenting and not connected - [x] fetch posts/comments we don't know but remote interaction was requested for ?
This commit is contained in:
committed by
Baptiste Gelez
parent
12efe721cc
commit
0d708e1639
@@ -253,6 +253,15 @@ impl User {
|
||||
User::from_id(c, link.href.as_ref()?, None).map_err(|(_, e)| e)
|
||||
}
|
||||
|
||||
pub fn fetch_remote_interact_uri(acct: &str) -> Result<String> {
|
||||
resolve(acct.to_owned(), true)?
|
||||
.links
|
||||
.into_iter()
|
||||
.find(|l| l.rel == "http://ostatus.org/schema/1.0/subscribe")
|
||||
.and_then(|l| l.template)
|
||||
.ok_or(Error::Webfinger)
|
||||
}
|
||||
|
||||
fn fetch(url: &str) -> Result<CustomPerson> {
|
||||
let mut res = Client::new()
|
||||
.get(url)
|
||||
@@ -640,7 +649,7 @@ impl User {
|
||||
links: vec![
|
||||
Link {
|
||||
rel: String::from("http://webfinger.net/rel/profile-page"),
|
||||
mime_type: None,
|
||||
mime_type: Some(String::from("text/html")),
|
||||
href: Some(self.ap_url.clone()),
|
||||
template: None,
|
||||
},
|
||||
@@ -660,6 +669,15 @@ impl User {
|
||||
href: Some(self.ap_url.clone()),
|
||||
template: None,
|
||||
},
|
||||
Link {
|
||||
rel: String::from("http://ostatus.org/schema/1.0/subscribe"),
|
||||
mime_type: None,
|
||||
href: None,
|
||||
template: Some(format!(
|
||||
"{}/remote_interact?{{uri}}",
|
||||
self.get_instance(conn)?.public_domain
|
||||
)),
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user