Implement Follow::to_activity07()

This commit is contained in:
Kitaiti Makoto 2022-04-24 03:38:36 +09:00
parent c5656971c9
commit 9343d3a120
1 changed files with 13 additions and 0 deletions

View File

@ -71,6 +71,19 @@ impl Follow {
Ok(act)
}
pub fn to_activity07(&self, conn: &Connection) -> Result<FollowAct07> {
let user = User::get(conn, self.follower_id)?;
let target = User::get(conn, self.following_id)?;
let target_id = target.ap_url.parse::<IriString>()?;
let mut act = FollowAct07::new(user.ap_url.parse::<IriString>()?, target_id.clone());
act.set_id(self.ap_url.parse::<IriString>()?);
act.set_many_tos(vec![target_id]);
act.set_many_ccs(vec![PUBLIC_VISIBILITY.parse::<IriString>()?]);
Ok(act)
}
pub fn notify(&self, conn: &Connection) -> Result<()> {
if User::get(conn, self.following_id)?.is_local() {
Notification::insert(