use std::{ops::Deref, sync::Arc}; use activitypub_federation::config::FederationConfig; use stack_up::{Configuration, Environment, Services}; use crate::{entity::user::User, error::AppError}; #[derive(Clone)] pub struct AppHandle(Arc); impl Deref for AppHandle { type Target = Arc; fn deref(&self) -> &Self::Target { &self.0 } } pub struct AppState { pub services: Services, } impl AppState { pub async fn new( services: Services, configuration: &Configuration, ) -> Result, AppError> { let user = User::new("sellershut", &services).await?; let domain = "localhost"; let config = FederationConfig::builder() .domain(domain) .signed_fetch_actor(&user) .app_data(AppHandle(Arc::new(Self { services }))) // .url_verifier(Box::new(MyUrlVerifier())) // TODO: could change this to env variable? .debug(configuration.application.env == Environment::Development) .build() .await?; Ok(config) } }