diff options
author | rtkay123 <dev@kanjala.com> | 2025-07-17 14:00:40 +0200 |
---|---|---|
committer | rtkay123 <dev@kanjala.com> | 2025-07-17 14:00:40 +0200 |
commit | 69fe55ad54468948c13af520a498ed4aeac194ed (patch) | |
tree | c7db25aa7cf615480e9b386064f232d2bec6ccc3 /src/state.rs | |
parent | 5fdb24b6a2cef7964a049e789ed90f883221d657 (diff) | |
download | sellershut-69fe55ad54468948c13af520a498ed4aeac194ed.tar.bz2 sellershut-69fe55ad54468948c13af520a498ed4aeac194ed.zip |
chore: convert to workspace
Diffstat (limited to 'src/state.rs')
-rw-r--r-- | src/state.rs | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/src/state.rs b/src/state.rs deleted file mode 100644 index 9129030..0000000 --- a/src/state.rs +++ /dev/null @@ -1,54 +0,0 @@ -use std::{ops::Deref, sync::Arc}; - -use activitypub_federation::config::FederationConfig; -use stack_up::{Configuration, Environment, Services}; - -use crate::{cnfg::LocalConfig, entity::user::User, error::AppError}; - -#[derive(Clone)] -pub struct AppHandle(Arc<AppState>); - -impl Deref for AppHandle { - type Target = Arc<AppState>; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -pub struct AppState { - pub services: Services, - pub environment: Environment, -} - -impl AppState { - pub async fn create( - services: Services, - configuration: &Configuration, - ) -> Result<FederationConfig<AppHandle>, AppError> { - 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(&warden_config.hostname) - .signed_fetch_actor(&user) - .app_data(AppHandle(Arc::new(Self { - services, - environment: configuration.application.env, - }))) - // .url_verifier(Box::new(MyUrlVerifier())) - // TODO: could change this to env variable? - .debug(configuration.application.env == Environment::Development) - .build() - .await?; - - Ok(config) - } -} |