diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index f857d462..dd08af41 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -1210,6 +1210,16 @@ impl AsObject for Post { } } +impl AsObject07 for Post { + type Error = Error; + type Output = Self; + + fn activity07(self, _conn: &DbConn, _actor: User, _id: &str) -> Result { + // TODO: check that _actor is actually one of the author? + Ok(self) + } +} + impl AsObject for Post { type Error = Error; type Output = (); @@ -1227,6 +1237,23 @@ impl AsObject for Post { } } +impl AsObject07 for Post { + type Error = Error; + type Output = (); + + fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result { + let can_delete = self + .get_authors(conn)? + .into_iter() + .any(|a| actor.id == a.id); + if can_delete { + self.delete(conn).map(|_| ()) + } else { + Err(Error::Unauthorized) + } + } +} + pub struct PostUpdate { pub ap_url: String, pub title: Option,