From 9343d3a120abe3b8075392a47250beb27b08f99a Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 24 Apr 2022 03:38:36 +0900 Subject: [PATCH] Implement Follow::to_activity07() --- plume-models/src/follows.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plume-models/src/follows.rs b/plume-models/src/follows.rs index 3ebbef82..b31611d9 100644 --- a/plume-models/src/follows.rs +++ b/plume-models/src/follows.rs @@ -71,6 +71,19 @@ impl Follow { Ok(act) } + pub fn to_activity07(&self, conn: &Connection) -> Result { + let user = User::get(conn, self.follower_id)?; + let target = User::get(conn, self.following_id)?; + let target_id = target.ap_url.parse::()?; + + let mut act = FollowAct07::new(user.ap_url.parse::()?, target_id.clone()); + act.set_id(self.ap_url.parse::()?); + act.set_many_tos(vec![target_id]); + act.set_many_ccs(vec![PUBLIC_VISIBILITY.parse::()?]); + + Ok(act) + } + pub fn notify(&self, conn: &Connection) -> Result<()> { if User::get(conn, self.following_id)?.is_local() { Notification::insert(