Avoid calling compute_id when we shouldn't
It should only be used at initialization, after we should prefer ap_url, as not everybody is using the same URLs as Plume.
This commit is contained in:
parent
514689cfc1
commit
5457a80eec
|
@ -175,12 +175,12 @@ impl Blog {
|
|||
pub fn webfinger(&self, conn: &PgConnection) -> Webfinger {
|
||||
Webfinger {
|
||||
subject: format!("acct:{}@{}", self.actor_id, self.get_instance(conn).public_domain),
|
||||
aliases: vec![self.compute_id(conn)],
|
||||
aliases: vec![self.ap_url.clone()],
|
||||
links: vec![
|
||||
Link {
|
||||
rel: String::from("http://webfinger.net/rel/profile-page"),
|
||||
mime_type: None,
|
||||
href: self.compute_id(conn)
|
||||
href: self.ap_url.clone()
|
||||
},
|
||||
Link {
|
||||
rel: String::from("http://schemas.google.com/g/2010#updates-from"),
|
||||
|
@ -190,7 +190,7 @@ impl Blog {
|
|||
Link {
|
||||
rel: String::from("self"),
|
||||
mime_type: Some(String::from("application/activity+json")),
|
||||
href: self.compute_id(conn)
|
||||
href: self.ap_url.clone()
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -259,8 +259,8 @@ impl APActor for Blog {
|
|||
}
|
||||
|
||||
impl sign::Signer for Blog {
|
||||
fn get_key_id(&self, conn: &PgConnection) -> String {
|
||||
format!("{}#main-key", self.compute_id(conn))
|
||||
fn get_key_id(&self, _conn: &PgConnection) -> String {
|
||||
format!("{}#main-key", self.ap_url)
|
||||
}
|
||||
|
||||
fn sign(&self, to_sign: String) -> Vec<u8> {
|
||||
|
|
|
@ -84,7 +84,7 @@ impl Comment {
|
|||
}
|
||||
|
||||
pub fn compute_id(&self, conn: &PgConnection) -> String {
|
||||
ap_url(format!("{}#comment-{}", self.get_post(conn).compute_id(conn), self.id))
|
||||
ap_url(format!("{}#comment-{}", self.get_post(conn).ap_url, self.id))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ impl Like {
|
|||
pub fn compute_id(&self, conn: &PgConnection) -> String {
|
||||
format!(
|
||||
"{}/like/{}",
|
||||
User::get(conn, self.user_id).unwrap().compute_id(conn),
|
||||
Post::get(conn, self.post_id).unwrap().compute_id(conn)
|
||||
User::get(conn, self.user_id).unwrap().ap_url,
|
||||
Post::get(conn, self.post_id).unwrap().ap_url
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ impl Post {
|
|||
content: Some(serde_json::to_value(self.content.clone()).unwrap()),
|
||||
published: Some(serde_json::to_value(self.creation_date).unwrap()),
|
||||
tag: Some(serde_json::to_value(mentions).unwrap()),
|
||||
url: Some(serde_json::to_value(self.compute_id(conn)).unwrap()),
|
||||
url: Some(serde_json::to_value(self.ap_url.clone()).unwrap()),
|
||||
to: Some(serde_json::to_value(to).unwrap()),
|
||||
cc: Some(serde_json::to_value(Vec::<serde_json::Value>::new()).unwrap()),
|
||||
..ObjectProperties::default()
|
||||
|
|
|
@ -34,8 +34,8 @@ impl Reshare {
|
|||
diesel::update(self)
|
||||
.set(reshares::ap_url.eq(format!(
|
||||
"{}/reshare/{}",
|
||||
User::get(conn, self.user_id).unwrap().compute_id(conn),
|
||||
Post::get(conn, self.post_id).unwrap().compute_id(conn)
|
||||
User::get(conn, self.user_id).unwrap().ap_url,
|
||||
Post::get(conn, self.post_id).unwrap().ap_url
|
||||
)))
|
||||
.get_result::<Reshare>(conn).expect("Couldn't update AP URL");
|
||||
}
|
||||
|
|
|
@ -309,10 +309,10 @@ impl User {
|
|||
pub fn into_activity(&self, conn: &PgConnection) -> Person {
|
||||
let mut actor = Person::default();
|
||||
actor.object_props = ObjectProperties {
|
||||
id: Some(serde_json::to_value(self.compute_id(conn)).unwrap()),
|
||||
id: Some(serde_json::to_value(self.ap_url.clone()).unwrap()),
|
||||
name: Some(serde_json::to_value(self.get_display_name()).unwrap()),
|
||||
summary: Some(serde_json::to_value(self.get_summary()).unwrap()),
|
||||
url: Some(serde_json::to_value(self.compute_id(conn)).unwrap()),
|
||||
url: Some(serde_json::to_value(self.ap_url.clone()).unwrap()),
|
||||
..ObjectProperties::default()
|
||||
};
|
||||
actor.ap_actor_props = ApActorProperties {
|
||||
|
@ -339,12 +339,12 @@ impl User {
|
|||
pub fn webfinger(&self, conn: &PgConnection) -> Webfinger {
|
||||
Webfinger {
|
||||
subject: format!("acct:{}@{}", self.username, self.get_instance(conn).public_domain),
|
||||
aliases: vec![self.compute_id(conn)],
|
||||
aliases: vec![self.ap_url.clone()],
|
||||
links: vec![
|
||||
Link {
|
||||
rel: String::from("http://webfinger.net/rel/profile-page"),
|
||||
mime_type: None,
|
||||
href: self.compute_id(conn)
|
||||
href: self.ap_url.clone()
|
||||
},
|
||||
Link {
|
||||
rel: String::from("http://schemas.google.com/g/2010#updates-from"),
|
||||
|
@ -354,7 +354,7 @@ impl User {
|
|||
Link {
|
||||
rel: String::from("self"),
|
||||
mime_type: Some(String::from("application/activity+json")),
|
||||
href: self.compute_id(conn)
|
||||
href: self.ap_url.clone()
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ impl APActor for User {
|
|||
let mut res = serde_json::Map::new();
|
||||
res.insert("publicKey".to_string(), json!({
|
||||
"id": self.get_key_id(conn),
|
||||
"owner": self.compute_id(conn),
|
||||
"owner": self.ap_url,
|
||||
"publicKeyPem": self.public_key
|
||||
}));
|
||||
res.insert("followers".to_string(), serde_json::Value::String(self.compute_box(conn, "followers")));
|
||||
|
@ -461,8 +461,8 @@ impl Inbox for User {
|
|||
}
|
||||
|
||||
impl Signer for User {
|
||||
fn get_key_id(&self, conn: &PgConnection) -> String {
|
||||
format!("{}#main-key", self.compute_id(conn))
|
||||
fn get_key_id(&self, _conn: &PgConnection) -> String {
|
||||
format!("{}#main-key", self.ap_url)
|
||||
}
|
||||
|
||||
fn sign(&self, to_sign: String) -> Vec<u8> {
|
||||
|
|
|
@ -206,7 +206,7 @@ fn inbox(name: String, conn: DbConn, data: String) -> String {
|
|||
#[get("/@/<name>/followers", format = "application/activity+json")]
|
||||
fn ap_followers(name: String, conn: DbConn) -> ActivityPub {
|
||||
let user = User::find_local(&*conn, name).unwrap();
|
||||
let followers = user.get_followers(&*conn).into_iter().map(|f| f.compute_id(&*conn)).collect::<Vec<String>>();
|
||||
let followers = user.get_followers(&*conn).into_iter().map(|f| f.ap_url).collect::<Vec<String>>();
|
||||
|
||||
let json = json!({
|
||||
"@context": context(),
|
||||
|
|
Loading…
Reference in New Issue