From bb682a1cc1769ff4556ac88ec320682162ec2bdd Mon Sep 17 00:00:00 2001 From: Bat Date: Mon, 18 Jun 2018 16:16:18 +0100 Subject: [PATCH] Don't sign activities for each target inbox, do it only once --- src/activity_pub/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/activity_pub/mod.rs b/src/activity_pub/mod.rs index af544aca..51d12d3e 100644 --- a/src/activity_pub/mod.rs +++ b/src/activity_pub/mod.rs @@ -76,18 +76,18 @@ impl<'r, O: Object> Responder<'r> for ActivityStream { } } -pub fn broadcast(conn: &PgConnection, sender: &S, act: A, to: Vec) { +pub fn broadcast(conn: &PgConnection, sender: &S, act: A, to: Vec) { let boxes = to.into_iter() .map(|u| u.get_shared_inbox_url().unwrap_or(u.get_inbox_url())) .collect::>() .unique(); + + let mut act = serde_json::to_value(act).unwrap(); + act["@context"] = context(); + let signed = act.sign(sender, conn); + for inbox in boxes { // TODO: run it in Sidekiq or something like that - - let mut act = serde_json::to_value(act.clone()).unwrap(); - act["@context"] = context(); - let signed = act.sign(sender, conn); - let res = Client::new() .post(&inbox[..]) .headers(request::headers())