diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index 4e368f58..2a5c97f2 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -23,7 +23,7 @@ use std::collections::HashSet; pub type LicensedArticle = CustomObject; -#[derive(Queryable, Identifiable, Clone, AsChangeset)] +#[derive(Queryable, Identifiable, Clone, AsChangeset, Debug)] #[changeset_options(treat_none_as_null = "true")] pub struct Post { pub id: i32, @@ -800,6 +800,25 @@ impl IntoId for Post { } } +#[derive(Clone, Debug)] +pub enum PostEvent { + PostPublished(Post), + PostUpdated(Post), + PostDeleted(Post), +} + +impl From for Post { + fn from(event: PostEvent) -> Self { + use PostEvent::*; + + match event { + PostPublished(post) => post, + PostUpdated(post) => post, + PostDeleted(post) => post, + } + } +} + #[cfg(test)] mod tests { use super::*;