diff options
| author | rtkay123 <dev@kanjala.com> | 2026-02-02 13:05:49 +0200 |
|---|---|---|
| committer | rtkay123 <dev@kanjala.com> | 2026-02-02 13:05:49 +0200 |
| commit | e06094f23ca861ea5ae4864d11fa8ce8b7d7aa2c (patch) | |
| tree | 27bbff5fd21711f99aaf579a76b1a0aca7869003 /src/server/state/mod.rs | |
| parent | 78f61ccdf66572d7432b5b627994038479103653 (diff) | |
| download | sellershut-e06094f23ca861ea5ae4864d11fa8ce8b7d7aa2c.tar.bz2 sellershut-e06094f23ca861ea5ae4864d11fa8ce8b7d7aa2c.zip | |
feat: oauth route
Diffstat (limited to 'src/server/state/mod.rs')
| -rw-r--r-- | src/server/state/mod.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/server/state/mod.rs b/src/server/state/mod.rs index 0726689..f5f731e 100644 --- a/src/server/state/mod.rs +++ b/src/server/state/mod.rs @@ -1,33 +1,34 @@ pub mod database; +pub mod federation; + +use std::sync::Arc; use sellershut_auth::{ClientOptions, OauthClient}; -use sqlx::PgPool; #[cfg(feature = "oauth-discord")] use url::Url; -use crate::config::Config; #[cfg(feature = "oauth-discord")] use crate::config::DiscordOauth; +use crate::{config::Config, server::driver::SellershutDriver}; +#[derive(Clone)] pub struct AppState { - database: PgPool, + driver: Arc<dyn SellershutDriver>, #[cfg(feature = "oauth-discord")] oauth_discord: OauthClient, } impl AppState { - pub async fn new(config: &Config) -> anyhow::Result<Self> { - let database = database::connect(&config.database).await?; - + pub async fn new(config: &Config, driver: impl SellershutDriver) -> anyhow::Result<Self> { Ok(Self { - database, + driver: Arc::new(driver), oauth_discord: discord_client(&config.oauth.discord, &config.oauth.oauth_redirect_url)?, }) } } #[cfg(feature = "oauth-discord")] -fn discord_client(disc: &DiscordOauth, redirect: &Url)->anyhow::Result<OauthClient> { +fn discord_client(disc: &DiscordOauth, redirect: &Url) -> anyhow::Result<OauthClient> { let discord_opts = ClientOptions::builder() .client_id(disc.client_id.to_owned()) .redirect_url(redirect.to_string()) |
