summaryrefslogtreecommitdiffstats
path: root/server/src/apub/user.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/user.rs
parent079ac091ebbeb2e3e1f91fba6c93b3e11e1c5fd6 (diff)
Making a trait function for follow and accept.
Diffstat (limited to 'server/src/apub/user.rs')
-rw-r--r--server/src/apub/user.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/server/src/apub/user.rs b/server/src/apub/user.rs
index 88238b5d..b4b3b35b 100644
--- a/server/src/apub/user.rs
+++ b/server/src/apub/user.rs
@@ -27,11 +27,16 @@ impl ToApub for User_ {
oprops.set_name_xsd_string(i.to_owned())?;
}
+ 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_inbox(self.get_inbox_url())?
.set_outbox(self.get_outbox_url())?
+ .set_endpoints(endpoint_props)?
.set_followers(self.get_followers_url())?
.set_following(self.get_following_url())?
.set_liked(self.get_liked_url())?;
@@ -48,6 +53,29 @@ impl ActorType for User_ {
fn public_key(&self) -> String {
self.public_key.to_owned().unwrap()
}
+
+ // TODO might be able to move this to a default trait fn
+ /// As a given local user, send out a follow request to a remote community.
+ fn send_follow(&self, follow_actor_id: &str) -> Result<(), Error> {
+ let mut follow = Follow::new();
+ follow
+ .object_props
+ .set_context_xsd_any_uri(context())?
+ // TODO: needs proper id
+ .set_id(self.actor_id.to_owned())?;
+ follow
+ .follow_props
+ .set_actor_xsd_any_uri(self.actor_id.to_owned())?
+ .set_object_xsd_any_uri(follow_actor_id)?;
+ let to = format!("{}/inbox", follow_actor_id);
+ send_activity(
+ &follow,
+ &self.private_key.as_ref().unwrap(),
+ &follow_actor_id,
+ vec![to],
+ )?;
+ Ok(())
+ }
}
impl FromApub for UserForm {