diff --git a/src/activity_pub/actor.rs b/src/activity_pub/actor.rs index 5d229f9..2699ace 100644 --- a/src/activity_pub/actor.rs +++ b/src/activity_pub/actor.rs @@ -36,6 +36,8 @@ pub trait Actor: Sized { fn get_actor_type() -> ActorType; + fn get_inbox_url(&self) -> String; + fn custom_props(&self, _conn: &PgConnection) -> serde_json::Map { serde_json::Map::new() } @@ -88,15 +90,15 @@ pub trait Actor: Sized { let signed = act.sign(sender, conn); let res = Client::new() - .post(&self.compute_inbox(conn)[..]) + .post(&self.get_inbox_url()[..]) .headers(request::headers()) .header(request::signature(sender, request::headers(), conn)) .header(request::digest(signed.to_string())) .body(signed.to_string()) .send(); match res { - Ok(_) => println!("Successfully sent activity to inbox"), - Err(_) => println!("Error while sending to inbox") + Ok(mut r) => println!("Successfully sent activity to inbox ({})\n\n{:?}", self.get_inbox_url(), r.text().unwrap()), + Err(e) => println!("Error while sending to inbox ({:?})", e) } } diff --git a/src/models/blogs.rs b/src/models/blogs.rs index 8f0825e..0ec72c4 100644 --- a/src/models/blogs.rs +++ b/src/models/blogs.rs @@ -126,6 +126,10 @@ impl Actor for Blog { ActorType::Blog } + fn get_inbox_url(&self) -> String { + self.inbox_url.clone() + } + fn from_url(conn: &PgConnection, url: String) -> Option { blogs::table.filter(blogs::ap_url.eq(url)) .limit(1) diff --git a/src/models/users.rs b/src/models/users.rs index 4fc7e04..4712441 100644 --- a/src/models/users.rs +++ b/src/models/users.rs @@ -263,6 +263,10 @@ impl Actor for User { ActorType::Person } + fn get_inbox_url(&self) -> String { + self.inbox_url.clone() + } + fn custom_props(&self, conn: &PgConnection) -> serde_json::Map { let mut res = serde_json::Map::new(); res.insert("publicKey".to_string(), json!({