diff options
Diffstat (limited to 'src/state.rs')
-rw-r--r-- | src/state.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/state.rs b/src/state.rs index d7c9136..5ced62e 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,7 +1,7 @@ use std::{ops::Deref, sync::Arc}; use activitypub_federation::config::FederationConfig; -use tokio::sync::RwLock; +use stack_up::{Configuration, Environment, Services}; use crate::{entity::user::User, error::AppError}; @@ -17,23 +17,24 @@ impl Deref for AppHandle { } pub struct AppState { - pub users: RwLock<Vec<User>>, + pub services: Services, } impl AppState { - pub async fn new() -> Result<FederationConfig<AppHandle>, AppError> { - let user = User::new("sellershut")?; + pub async fn new( + services: Services, + configuration: &Configuration, + ) -> Result<FederationConfig<AppHandle>, 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 { - users: RwLock::new(vec![user]), - }))) + .app_data(AppHandle(Arc::new(Self { services }))) // .url_verifier(Box::new(MyUrlVerifier())) // TODO: could change this to env variable? - .debug(cfg!(debug_assertions)) + .debug(configuration.application.env == Environment::Development) .build() .await?; |