use super::super::Lifecycle;
use super::{SiteAct, SiteError};
use crate::auth_lys::live::drafts::ApprovalTransition;
impl Lifecycle {
pub fn apply_outright(
&self,
act: &SiteAct,
grant: &str,
operation: &str,
words: &str,
at_ms: u64,
) -> Result<serde_json::Value, SiteError> {
let transition = ApprovalTransition {
draft: format!("grant:{grant}"),
digest: lys_pass::drafts::request_digest(words),
approved_by: vec!["lys".to_owned()],
executed_at_ms: at_ms,
};
let mut registry = self.lock()?;
let mut snapshot = Self::snapshot(®istry);
self.apply_site_act(&mut snapshot, act, &transition, at_ms, ®istry.trials)?;
super::storage::commit(self, &mut registry, &snapshot)?;
drop(registry);
self.refresh_sites()?;
Ok(serde_json::json!({
"state": "executed",
"grant": grant,
"approved_by": "lys",
"responsible": act.responsible,
"operation": operation,
}))
}
}
#[cfg(test)]
#[path = "outright_tests.rs"]
mod tests;