use chyabrung::prelude::*;
#[derive(Debug, Clone, Serialize, Deserialize, Model)]
#[model(timestamps)]
pub struct Post {
pub id: i64,
pub user_id: i64,
pub title: String,
pub body: String,
pub published: bool,
pub created_at: Option<String>,
pub updated_at: Option<String>,
}
impl Post {
pub fn can_be_changed_by(&self, user: &Identity, permission: &str) -> bool {
user.id == self.user_id.to_string() || user.can(permission)
}
}