From 0de7859ca868019f526f83fe7f822f3971c00ebf Mon Sep 17 00:00:00 2001 From: Bat Date: Thu, 3 May 2018 22:19:47 +0100 Subject: [PATCH] Explictly send articles to followers --- src/models/posts.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/models/posts.rs b/src/models/posts.rs index 59fa888a..54b442cf 100644 --- a/src/models/posts.rs +++ b/src/models/posts.rs @@ -111,6 +111,14 @@ fn compute_id(&self, conn: &PgConnection) -> String { } fn serialize(&self, conn: &PgConnection) -> serde_json::Value { + let followers = self.post.get_authors(conn).into_iter().map(|a| a.get_followers(conn)).collect::>>(); + let mut to = followers.into_iter().fold(vec![], |mut acc, f| { + for x in f { + acc.push(x.ap_url); + } + acc + }); + to.push(PUBLIC_VISIBILTY.to_string()); json!({ "type": "Note", "attributedTo": self.post.get_authors(conn).into_iter().map(|a| a.compute_id(conn)).collect::>(), @@ -123,7 +131,7 @@ fn compute_id(&self, conn: &PgConnection) -> String { "tag": [], // TODO: "updated": "updated", // TODO: "url": "url", - "to": [ PUBLIC_VISIBILTY ] + "to": to }) } }