diff --git a/src/models/blogs.rs b/src/models/blogs.rs index dc779f6..eb2d3ab 100644 --- a/src/models/blogs.rs +++ b/src/models/blogs.rs @@ -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 { diff --git a/src/models/comments.rs b/src/models/comments.rs index 326567d..9deaa1a 100644 --- a/src/models/comments.rs +++ b/src/models/comments.rs @@ -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)) } } diff --git a/src/models/likes.rs b/src/models/likes.rs index 38a4a19..0f18b10 100644 --- a/src/models/likes.rs +++ b/src/models/likes.rs @@ -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 ) } } diff --git a/src/models/posts.rs b/src/models/posts.rs index bf0e7fe..9907ac5 100644 --- a/src/models/posts.rs +++ b/src/models/posts.rs @@ -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::::new()).unwrap()), ..ObjectProperties::default() diff --git a/src/models/reshares.rs b/src/models/reshares.rs index 40a210d..bc29f4f 100644 --- a/src/models/reshares.rs +++ b/src/models/reshares.rs @@ -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::(conn).expect("Couldn't update AP URL"); } diff --git a/src/models/users.rs b/src/models/users.rs index ee7639c..ef5d83f 100644 --- a/src/models/users.rs +++ b/src/models/users.rs @@ -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 { diff --git a/src/routes/user.rs b/src/routes/user.rs index da78cf6..e49df65 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -206,7 +206,7 @@ fn inbox(name: String, conn: DbConn, data: String) -> String { #[get("/@//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::>(); + let followers = user.get_followers(&*conn).into_iter().map(|f| f.ap_url).collect::>(); let json = json!({ "@context": context(),