Implement AsObject07<User, Undo07, &DbConn> for Follow

This commit is contained in:
Kitaiti Makoto 2022-04-24 06:11:54 +09:00
parent fb5027becd
commit 73009818f2
1 changed files with 21 additions and 0 deletions

View File

@ -363,6 +363,27 @@ impl AsObject<User, Undo, &DbConn> for Follow {
}
}
impl AsObject07<User, Undo07, &DbConn> for Follow {
type Error = Error;
type Output = ();
fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
let conn = conn;
if self.follower_id == actor.id {
diesel::delete(&self).execute(&**conn)?;
// delete associated notification if any
if let Ok(notif) = Notification::find(conn, notification_kind::FOLLOW, self.id) {
diesel::delete(&notif).execute(&**conn)?;
}
Ok(())
} else {
Err(Error::Unauthorized)
}
}
}
impl IntoId for Follow {
fn into_id(self) -> Id {
Id::new(self.ap_url)