Browse Source

Session/crypto store configuration

pull/1/head
Stephen 10 months ago
parent
commit
7e14b91cac
4 changed files with 17 additions and 4 deletions
  1. +1
    -1
      Cargo.lock
  2. +1
    -0
      config.example
  3. +1
    -0
      src/config.rs
  4. +14
    -3
      src/main.rs

+ 1
- 1
Cargo.lock View File

@ -124,7 +124,7 @@ dependencies = [
[[package]]
name = "cat_disruptor_7000"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"async-trait",
"matrix-sdk",


+ 1
- 0
config.example View File

@ -2,4 +2,5 @@
"homeserver_url": "changeme",
"username": "changeme",
"password": "changeme"
"store_path": "crypto"
}

+ 1
- 0
src/config.rs View File

@ -7,6 +7,7 @@ pub struct Config {
pub homeserver_url: String,
pub username: String,
pub password: String,
pub store_path: String
}
pub fn get_config() -> Config {


+ 14
- 3
src/main.rs View File

@ -1,4 +1,6 @@
use std::collections::HashMap;
use std::path::Path;
use std::fs;
use url::Url;
@ -99,9 +101,9 @@ impl EventEmitter for EventCallback {
async fn login(
homeserver_url: String,
username: String,
password: String
password: String,
config: ClientConfig
) -> Result<(), matrix_sdk::Error> {
let config = ClientConfig::new();
let homeserver_url = Url::parse(&homeserver_url).expect("Couldn't parse the homeserver URL");
let mut client = Client::new_with_config(homeserver_url, config).unwrap();
@ -126,6 +128,15 @@ async fn main() -> Result<(), matrix_sdk::Error> {
config.password == "changeme" {
panic!("Please update the values in the config file!");
}
let store_path = fs::canonicalize(Path::new(&config.store_path)).unwrap();
if !store_path.exists() {
fs::create_dir(config.store_path.clone()).unwrap();
}
let matrix_config = ClientConfig::new()
.store_path(store_path);
login(config.homeserver_url, config.username, config.password).await
login(config.homeserver_url, config.username, config.password, matrix_config).await
}

Loading…
Cancel
Save