summaryrefslogtreecommitdiffstats
path: root/server/src/apub/post.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/apub/post.rs')
-rw-r--r--server/src/apub/post.rs86
1 files changed, 86 insertions, 0 deletions
diff --git a/server/src/apub/post.rs b/server/src/apub/post.rs
index 5a7383c0..2d1f1c71 100644
--- a/server/src/apub/post.rs
+++ b/server/src/apub/post.rs
@@ -263,6 +263,92 @@ impl ApubObjectType for Post {
)?;
Ok(())
}
+
+ fn send_remove(&self, mod_: &User_, conn: &PgConnection) -> Result<(), Error> {
+ let page = self.to_apub(conn)?;
+ let community = Community::read(conn, self.community_id)?;
+ let id = format!("{}/remove/{}", self.ap_id, uuid::Uuid::new_v4());
+ let mut remove = Remove::default();
+
+ populate_object_props(
+ &mut remove.object_props,
+ &community.get_followers_url(),
+ &id,
+ )?;
+
+ remove
+ .remove_props
+ .set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
+ .set_object_base_box(page)?;
+
+ // Insert the sent activity into the activity table
+ let activity_form = activity::ActivityForm {
+ user_id: mod_.id,
+ data: serde_json::to_value(&remove)?,
+ local: true,
+ updated: None,
+ };
+ activity::Activity::create(&conn, &activity_form)?;
+
+ let community = Community::read(conn, self.community_id)?;
+ send_activity(
+ &remove,
+ &mod_.private_key.as_ref().unwrap(),
+ &mod_.actor_id,
+ community.get_follower_inboxes(&conn)?,
+ )?;
+ Ok(())
+ }
+ fn send_undo_remove(&self, mod_: &User_, conn: &PgConnection) -> Result<(), Error> {
+ let page = self.to_apub(conn)?;
+ let community = Community::read(conn, self.community_id)?;
+ let id = format!("{}/remove/{}", self.ap_id, uuid::Uuid::new_v4());
+ let mut remove = Remove::default();
+
+ populate_object_props(
+ &mut remove.object_props,
+ &community.get_followers_url(),
+ &id,
+ )?;
+
+ remove
+ .remove_props
+ .set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
+ .set_object_base_box(page)?;
+
+ // Undo that fake activity
+ let undo_id = format!("{}/undo/remove/{}", self.ap_id, uuid::Uuid::new_v4());
+ let mut undo = Undo::default();
+
+ populate_object_props(
+ &mut undo.object_props,
+ &community.get_followers_url(),
+ &undo_id,
+ )?;
+
+ undo
+ .undo_props
+ .set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
+ .set_object_base_box(remove)?;
+
+ // Insert the sent activity into the activity table
+ let activity_form = activity::ActivityForm {
+ user_id: mod_.id,
+ data: serde_json::to_value(&undo)?,
+ local: true,
+ updated: None,
+ };
+ activity::Activity::create(&conn, &activity_form)?;
+
+ let community = Community::read(conn, self.community_id)?;
+ send_activity(
+ &undo,
+ &mod_.private_key.as_ref().unwrap(),
+ &mod_.actor_id,
+ community.get_follower_inboxes(&conn)?,
+ )?;
+ Ok(())
+ }
}
impl ApubLikeableType for Post {