Post activities to the correct inbox
Don't assume everyone is following Plume's routing
This commit is contained in:
		
							parent
							
								
									b36e83049c
								
							
						
					
					
						commit
						d3c3180038
					
				| @ -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<String, serde_json::Value> { | ||||
|         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) | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -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<Blog> { | ||||
|         blogs::table.filter(blogs::ap_url.eq(url)) | ||||
|             .limit(1) | ||||
|  | ||||
| @ -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<String, serde_json::Value> { | ||||
|         let mut res = serde_json::Map::new(); | ||||
|         res.insert("publicKey".to_string(), json!({ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user