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
|
||||
.context("Failed to connect to Postgres")?;
|
||||
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(())
|
||||
|
@ -57,10 +57,11 @@ pub enum UserCommand {
|
||||
}
|
||||
|
||||
/// Handles a user command from the command-line interface.
|
||||
pub async fn handle_user_command(command: UserCommand, config: &Configuration) -> eyre::Result<()> {
|
||||
let store = IdCoopStore::connect(&config.postgres.connect)
|
||||
.await
|
||||
.context("Failed to connect to Postgres")?;
|
||||
pub async fn handle_user_command(
|
||||
command: UserCommand,
|
||||
config: &Configuration,
|
||||
store: &IdCoopStore,
|
||||
) -> eyre::Result<()> {
|
||||
match command {
|
||||
UserCommand::Add { username, locked } => {
|
||||
store
|
||||
|
Loading…
Reference in New Issue
Block a user