Allow passing in a store to handle_user_command
Signed-off-by: Olivier 'reivilibre <olivier@librepush.net>
This commit is contained in:
parent
d088af98d8
commit
67e7d6bf5f
@ -103,9 +103,14 @@ async fn main() -> eyre::Result<()> {
|
|||||||
.await
|
.await
|
||||||
.context("Failed to connect to Postgres")?;
|
.context("Failed to connect to Postgres")?;
|
||||||
let secrets = SecretConfig::try_new(&config).await?;
|
let secrets = SecretConfig::try_new(&config).await?;
|
||||||
web::serve(bind, Arc::new(store), Arc::new(config), Arc::new(secrets)).await?
|
web::serve(bind, Arc::new(store), Arc::new(config), Arc::new(secrets)).await?;
|
||||||
|
}
|
||||||
|
Subcommand::User { cmd } => {
|
||||||
|
let store = IdCoopStore::connect(&config.postgres.connect)
|
||||||
|
.await
|
||||||
|
.context("Failed to connect to Postgres")?;
|
||||||
|
handle_user_command(cmd, &config, &store).await?;
|
||||||
}
|
}
|
||||||
Subcommand::User { cmd } => handle_user_command(cmd, &config).await?,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -57,10 +57,11 @@ pub enum UserCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a user command from the command-line interface.
|
/// Handles a user command from the command-line interface.
|
||||||
pub async fn handle_user_command(command: UserCommand, config: &Configuration) -> eyre::Result<()> {
|
pub async fn handle_user_command(
|
||||||
let store = IdCoopStore::connect(&config.postgres.connect)
|
command: UserCommand,
|
||||||
.await
|
config: &Configuration,
|
||||||
.context("Failed to connect to Postgres")?;
|
store: &IdCoopStore,
|
||||||
|
) -> eyre::Result<()> {
|
||||||
match command {
|
match command {
|
||||||
UserCommand::Add { username, locked } => {
|
UserCommand::Add { username, locked } => {
|
||||||
store
|
store
|
||||||
|
Loading…
Reference in New Issue
Block a user