diff --git a/plume-models/src/follows.rs b/plume-models/src/follows.rs index ce853d1c..8f597d83 100644 --- a/plume-models/src/follows.rs +++ b/plume-models/src/follows.rs @@ -363,6 +363,27 @@ impl AsObject for Follow { } } +impl AsObject07 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(¬if).execute(&**conn)?; + } + + Ok(()) + } else { + Err(Error::Unauthorized) + } + } +} + impl IntoId for Follow { fn into_id(self) -> Id { Id::new(self.ap_url)