use super::*;
use crate::query_msg::QueryMsg;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Notification {
Qms(Project, QueryMsg),
}
impl Notification {
pub fn notify(&self) -> AnyResult<()> {
match self {
Self::Qms(project, message) => message.notify(project),
}
}
pub fn pop_up(&self) -> bool {
match self {
Self::Qms(project, message) => message.pop_up(project),
}
}
}
#[async_trait]
pub trait NotifDigest: DynClone + fmt::Debug + Send + Sync {
fn update_date_range(&mut self);
async fn notifications(
&mut self,
projects: &[Project],
viewer: &Staff,
) -> Result<Vec<Notification>, DatabaseError>;
async fn mark_instantiated(
&self,
notif: &Notification,
viewer: &Staff,
target: InstantiationState,
) -> Result<(), ModificationError>;
async fn notifications_once(
&mut self,
projects: &[Project],
viewer: &Staff,
) -> Result<Vec<Notification>, DatabaseError>;
}
dyn_clone::clone_trait_object!(NotifDigest);