From a69c24e561c8ae16dc730f7713f8d8da0bd25e0e Mon Sep 17 00:00:00 2001 From: rtkay123 Date: Tue, 15 Jul 2025 08:42:19 +0200 Subject: feat: persist with sqlx --- src/state.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/state.rs') 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>, + pub services: Services, } impl AppState { - pub async fn new() -> Result, AppError> { - let user = User::new("sellershut")?; + 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 { - 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?; -- cgit v1.2.3