summaryrefslogtreecommitdiffstats
path: root/server/src/apub/community.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/community.rs
parent9c30b37d57ee241ea1b4f1cbc5f6ee0d631c5acf (diff)
Adding activity table inserts.
Diffstat (limited to 'server/src/apub/community.rs')
-rw-r--r--server/src/apub/community.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/server/src/apub/community.rs b/server/src/apub/community.rs
index d66bbc01..f5e4f44d 100644
--- a/server/src/apub/community.rs
+++ b/server/src/apub/community.rs
@@ -57,7 +57,7 @@ impl ActorType for Community {
}
/// As a local community, accept the follow request from a remote user.
- fn send_accept_follow(&self, follow: &Follow) -> Result<(), Error> {
+ fn send_accept_follow(&self, follow: &Follow, conn: &PgConnection) -> Result<(), Error> {
let actor_uri = follow
.follow_props
.get_actor_xsd_any_uri()
@@ -65,22 +65,28 @@ impl ActorType for Community {
.to_string();
let mut accept = Accept::new();
+ // TODO using a fake accept id
+ let id = format!("{}/accept/{}", self.actor_id, uuid::Uuid::new_v4());
+ //follow
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(),
- )?;
+ .set_id(id)?;
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);
+
+ // Insert the sent activity into the activity table
+ let activity_form = activity::ActivityForm {
+ user_id: self.creator_id,
+ data: serde_json::to_value(&accept)?,
+ local: true,
+ updated: None,
+ };
+ activity::Activity::create(&conn, &activity_form)?;
+
send_activity(
&accept,
&self.private_key.to_owned().unwrap(),