diff options
Diffstat (limited to 'src/state.rs')
-rw-r--r-- | src/state.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/state.rs b/src/state.rs index 5ced62e..1ae6caa 100644 --- a/src/state.rs +++ b/src/state.rs @@ -3,7 +3,7 @@ use std::{ops::Deref, sync::Arc}; use activitypub_federation::config::FederationConfig; use stack_up::{Configuration, Environment, Services}; -use crate::{entity::user::User, error::AppError}; +use crate::{cnfg::LocalConfig, entity::user::User, error::AppError}; #[derive(Clone)] pub struct AppHandle(Arc<AppState>); @@ -21,15 +21,22 @@ pub struct AppState { } impl AppState { - pub async fn new( + pub async fn create( services: Services, configuration: &Configuration, ) -> Result<FederationConfig<AppHandle>, AppError> { - let user = User::new("sellershut", &services).await?; - let domain = "localhost"; + let warden_config: LocalConfig = serde_json::from_value(configuration.misc.clone())?; + + let user = User::new( + &warden_config.instance_name, + &warden_config.hostname, + &services, + configuration.application.env, + ) + .await?; let config = FederationConfig::builder() - .domain(domain) + .domain(&warden_config.hostname) .signed_fetch_actor(&user) .app_data(AppHandle(Arc::new(Self { services }))) // .url_verifier(Box::new(MyUrlVerifier())) |