summaryrefslogtreecommitdiffstats
path: root/src/state.rs
diff options
context:
space:
mode:
authorrtkay123 <dev@kanjala.com>2025-07-15 08:42:19 +0200
committerrtkay123 <dev@kanjala.com>2025-07-15 08:42:19 +0200
commita69c24e561c8ae16dc730f7713f8d8da0bd25e0e (patch)
tree32878bf97b1adf2da14c8e3da7265c8937b89650 /src/state.rs
parenta64eb6b08f2f8d22cf129fba39e1bb2c66bb3fad (diff)
downloadsellershut-a69c24e561c8ae16dc730f7713f8d8da0bd25e0e.tar.bz2
sellershut-a69c24e561c8ae16dc730f7713f8d8da0bd25e0e.zip
feat: persist with sqlx
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs17
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?;