Merge remote-tracking branch 'origin/no-send-blocked' into no-send-blocked-dess

This commit is contained in:
Dessalines 2020-10-06 12:33:18 -05:00
commit 30431199cf

View file

@ -203,15 +203,15 @@ where
insert_activity(actor.user_id(), activity.clone(), true, pool).await?;
}
// TODO: it would make sense to create a separate task for each destination server
for t in to {
let message = SendActivityTask {
activity: serialised_activity,
to,
activity: serialised_activity.to_owned(),
to: t,
actor_id: actor.actor_id()?,
private_key: actor.private_key().context(location_info!())?,
};
activity_sender.queue::<SendActivityTask>(message)?;
}
Ok(())
}
@ -219,7 +219,7 @@ where
#[derive(Clone, Debug, Deserialize, Serialize)]
struct SendActivityTask {
activity: String,
to: Vec<Url>,
to: Url,
actor_id: Url,
private_key: String,
}
@ -234,13 +234,12 @@ impl ActixJob for SendActivityTask {
fn run(self, state: Self::State) -> Self::Future {
Box::pin(async move {
for to_url in &self.to {
let mut headers = BTreeMap::<String, String>::new();
headers.insert("Content-Type".into(), "application/json".into());
let result = sign_and_send(
&state.client,
headers,
to_url,
&self.to,
self.activity.clone(),
&self.actor_id,
self.private_key.to_owned(),
@ -252,10 +251,9 @@ impl ActixJob for SendActivityTask {
return Err(anyhow!(
"Failed to send activity {} to {}",
&self.activity,
to_url
self.to
));
}
}
Ok(())
})
}