summaryrefslogtreecommitdiffstats
path: root/server/src/apub/community.rs
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-04-27 12:57:00 -0400
committerDessalines <tyhou13@gmx.com>2020-04-27 12:57:00 -0400
commit22abbebd41d586298c62bb6a45efa7a96d998049 (patch)
tree60c31f49e9cee360cd06edc18eb53f93e953d6b7 /server/src/apub/community.rs
parent3ce061836242813730ec0b63240097347647dfc4 (diff)
Lots of additions to federation.
- Added a shared inbox. - Added federated comments, comment updates, and tests. - Abstracted ap object sends into a common trait.
Diffstat (limited to 'server/src/apub/community.rs')
-rw-r--r--server/src/apub/community.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/server/src/apub/community.rs b/server/src/apub/community.rs
index bc984b25..d66bbc01 100644
--- a/server/src/apub/community.rs
+++ b/server/src/apub/community.rs
@@ -89,6 +89,32 @@ impl ActorType for Community {
)?;
Ok(())
}
+
+ /// For a given community, returns the inboxes of all followers.
+ fn get_follower_inboxes(&self, conn: &PgConnection) -> Result<Vec<String>, Error> {
+ debug!("got here.");
+
+ Ok(
+ CommunityFollowerView::for_community(conn, self.id)?
+ .into_iter()
+ // TODO eventually this will have to use the inbox or shared_inbox column, meaning that view
+ // will have to change
+ .map(|c| {
+ // If the user is local, but the community isn't, get the community shared inbox
+ // and vice versa
+ if c.user_local && !c.community_local {
+ get_shared_inbox(&c.community_actor_id)
+ } else if !c.user_local && c.community_local {
+ get_shared_inbox(&c.user_actor_id)
+ } else {
+ "".to_string()
+ }
+ })
+ .filter(|s| !s.is_empty())
+ .unique()
+ .collect(),
+ )
+ }
}
impl FromApub for CommunityForm {