use anyhow::Result; use axum::{extract::State, response::IntoResponse, Form}; use axum_extra::response::Html; use serde::Deserialize; use crate::{ errors::SupercellError, storage::{denylist_remove, denylist_upsert, feed_content_purge_aturi}, }; use super::context::WebContext; #[derive(Deserialize, Default)] pub struct AdminForm { pub action: Option, pub did: Option, pub reason: Option, pub aturi: Option, pub feed: Option, } pub async fn handle_admin( State(web_context): State, Form(form): Form, ) -> Result { if let Some(action) = form.action { match action.as_str() { "purge" => { if let Some(aturi) = form.aturi { let feed = form.feed.filter(|s| !s.is_empty()); tracing::debug!("purging at-uri: {:?} with feed: {:?}", aturi, feed); feed_content_purge_aturi(&web_context.pool, &aturi, &feed).await?; } } "deny" => { if let Some(did) = form.did { let reason = form.reason.unwrap_or("n/a".to_string()); denylist_upsert(&web_context.pool, &did, &reason).await?; } } "allow" => { if let Some(did) = form.did { denylist_remove(&web_context.pool, &did).await?; } } _ => {} } } Ok(Html( r#" Supercell Admin

Purge AT-URI


Denylist Add


Denylist Remove


"#, )) }