liminal_server/services/site/
outright.rs1use super::super::Lifecycle;
9use super::{SiteAct, SiteError};
10use crate::auth_lys::live::drafts::ApprovalTransition;
11
12impl Lifecycle {
13 pub fn apply_outright(
18 &self,
19 act: &SiteAct,
20 grant: &str,
21 operation: &str,
22 words: &str,
23 at_ms: u64,
24 ) -> Result<serde_json::Value, SiteError> {
25 let transition = ApprovalTransition {
26 draft: format!("grant:{grant}"),
27 digest: lys_pass::drafts::request_digest(words),
28 approved_by: vec!["lys".to_owned()],
29 executed_at_ms: at_ms,
30 };
31 let mut registry = self.lock()?;
32 let mut snapshot = Self::snapshot(®istry);
33 self.apply_site_act(&mut snapshot, act, &transition, at_ms, ®istry.trials)?;
34 super::storage::commit(self, &mut registry, &snapshot)?;
35 drop(registry);
36 self.refresh_sites()?;
37 Ok(serde_json::json!({
38 "state": "executed",
39 "grant": grant,
40 "approved_by": "lys",
41 "responsible": act.responsible,
42 "operation": operation,
43 }))
44 }
45}
46
47#[cfg(test)]
48#[path = "outright_tests.rs"]
49mod tests;