We were previously using the GoSbot keystore path by default. This PR introduces a Keystore enum and adds it as an argument to the Sbot::init method.
Here are the relevant code changes:
/// Keystore selector to specify the location of the secret file.
///
/// This enum is used when initiating a connection with an sbot instance.
pubenumKeystore{/// Patchwork default keystore path: `.ssb/secret` in the user's home directory.
Patchwork,/// GoSbot default keystore path: `.ssb-go/secret` in the user's home directory.
GoSbot,}
pubasyncfninit(keystore: Keystore,ip_port: Option<String>,net_id: Option<String>,)-> Result<Sbot,GolgiError>{// ...
letOwnedIdentity{pk,sk,id}=matchkeystore{Keystore::Patchwork=>keystore::from_patchwork_local().await.expect("couldn't read local secret"),Keystore::GoSbot=>keystore::from_gosbot_local().await.expect("couldn't read local secret"),};
We were previously using the GoSbot keystore path by default. This PR introduces a `Keystore enum` and adds it as an argument to the `Sbot::init` method.
Here are the relevant code changes:
```rust
/// Keystore selector to specify the location of the secret file.
///
/// This enum is used when initiating a connection with an sbot instance.
pub enum Keystore {
/// Patchwork default keystore path: `.ssb/secret` in the user's home directory.
Patchwork,
/// GoSbot default keystore path: `.ssb-go/secret` in the user's home directory.
GoSbot,
}
```
```rust
pub async fn init(
keystore: Keystore,
ip_port: Option<String>,
net_id: Option<String>,
) -> Result<Sbot, GolgiError> {
// ...
let OwnedIdentity { pk, sk, id } = match keystore {
Keystore::Patchwork => keystore::from_patchwork_local()
.await
.expect("couldn't read local secret"),
Keystore::GoSbot => keystore::from_gosbot_local()
.await
.expect("couldn't read local secret"),
};
```
And it's invoked like this:
```rust
let mut sbot_client = Sbot::init(Keystore::Patchwork, None, None).await?;
```
CC: @notplants
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
We were previously using the GoSbot keystore path by default. This PR introduces a
Keystore enumand adds it as an argument to theSbot::initmethod.Here are the relevant code changes:
And it's invoked like this:
CC: @notplants
looks good!
cool that it takes advantage of the work already in kuska-ssb, nice detective work