summaryrefslogtreecommitdiffstats
path: root/server/src/apub/community.rs
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-04-26 13:20:42 -0400
committerDessalines <tyhou13@gmx.com>2020-04-26 13:20:42 -0400
commit3ce061836242813730ec0b63240097347647dfc4 (patch)
treed6ebe9074753b4a92e4d4d94ba6b4b2d0770ea4d /server/src/apub/community.rs
parent079ac091ebbeb2e3e1f91fba6c93b3e11e1c5fd6 (diff)
Making a trait function for follow and accept.
Diffstat (limited to 'server/src/apub/community.rs')
-rw-r--r--server/src/apub/community.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/server/src/apub/community.rs b/server/src/apub/community.rs
index e74a5fd1..bc984b25 100644
--- a/server/src/apub/community.rs
+++ b/server/src/apub/community.rs
@@ -30,12 +30,17 @@ impl ToApub for Community {
oprops.set_summary_xsd_string(d)?;
}
+ let mut endpoint_props = EndpointProperties::default();
+
+ endpoint_props.set_shared_inbox(self.get_shared_inbox_url())?;
+
let mut actor_props = ApActorProperties::default();
actor_props
.set_preferred_username(self.title.to_owned())?
.set_inbox(self.get_inbox_url())?
.set_outbox(self.get_outbox_url())?
+ .set_endpoints(endpoint_props)?
.set_followers(self.get_followers_url())?;
Ok(group.extend(actor_props).extend(self.get_public_key_ext()))
@@ -50,6 +55,40 @@ impl ActorType for Community {
fn public_key(&self) -> String {
self.public_key.to_owned().unwrap()
}
+
+ /// As a local community, accept the follow request from a remote user.
+ fn send_accept_follow(&self, follow: &Follow) -> Result<(), Error> {
+ let actor_uri = follow
+ .follow_props
+ .get_actor_xsd_any_uri()
+ .unwrap()
+ .to_string();
+
+ let mut accept = Accept::new();
+ accept
+ .object_props
+ .set_context_xsd_any_uri(context())?
+ // TODO: needs proper id
+ .set_id(
+ follow
+ .follow_props
+ .get_actor_xsd_any_uri()
+ .unwrap()
+ .to_string(),
+ )?;
+ accept
+ .accept_props
+ .set_actor_xsd_any_uri(self.actor_id.to_owned())?
+ .set_object_base_box(BaseBox::from_concrete(follow.clone())?)?;
+ let to = format!("{}/inbox", actor_uri);
+ send_activity(
+ &accept,
+ &self.private_key.to_owned().unwrap(),
+ &self.actor_id,
+ vec![to],
+ )?;
+ Ok(())
+ }
}
impl FromApub for CommunityForm {