summaryrefslogtreecommitdiffstats
path: root/server/src/apub/user.rs
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-04-27 18:17:02 -0400
committerDessalines <tyhou13@gmx.com>2020-04-27 18:17:02 -0400
commit70060c27b2f40ef2de0c0ea37d3d69e202ab8c02 (patch)
tree20f408714ab575852648b525bb3524fb596588d9 /server/src/apub/user.rs
parent9c30b37d57ee241ea1b4f1cbc5f6ee0d631c5acf (diff)
Adding activity table inserts.
Diffstat (limited to 'server/src/apub/user.rs')
-rw-r--r--server/src/apub/user.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/server/src/apub/user.rs b/server/src/apub/user.rs
index b4b3b35b..bb9f064c 100644
--- a/server/src/apub/user.rs
+++ b/server/src/apub/user.rs
@@ -54,20 +54,32 @@ impl ActorType for User_ {
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> {
+ fn send_follow(&self, follow_actor_id: &str, conn: &PgConnection) -> Result<(), Error> {
let mut follow = Follow::new();
+
+ // TODO using a fake accept id
+ let id = format!("{}/follow/{}", self.actor_id, uuid::Uuid::new_v4());
+
follow
.object_props
.set_context_xsd_any_uri(context())?
- // TODO: needs proper id
- .set_id(self.actor_id.to_owned())?;
+ .set_id(id)?;
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);
+
+ // Insert the sent activity into the activity table
+ let activity_form = activity::ActivityForm {
+ user_id: self.id,
+ data: serde_json::to_value(&follow)?,
+ local: true,
+ updated: None,
+ };
+ activity::Activity::create(&conn, &activity_form)?;
+
send_activity(
&follow,
&self.private_key.as_ref().unwrap(),