trace_share_core/
revocation.rs1use anyhow::Result;
2use chrono::Utc;
3
4use crate::{config::AppConfig, state::StateStore, worker::push_revocation};
5
6pub fn revoke_local(store: &StateStore, episode_id: &str, reason: Option<&str>) -> Result<()> {
7 store.upsert_revocation(episode_id, reason, &Utc::now().to_rfc3339(), "pending")
8}
9
10pub async fn sync_revocations(config: &AppConfig, store: &StateStore) -> Result<usize> {
11 let pending = store.pending_revocations()?;
12 let mut pushed = 0usize;
13
14 for item in pending {
15 push_revocation(
16 config,
17 &item.episode_id,
18 &item.revoked_at,
19 item.reason.as_deref(),
20 )
21 .await?;
22 store.mark_revocation_pushed(&item.episode_id)?;
23 pushed += 1;
24 }
25
26 Ok(pushed)
27}