this repo has no description
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 8fb9f80a64990a88a0ef24d3d6ed06bf79941e79 60 lines 1.7 kB view raw
1use websocket::sync::client::ClientBuilder; 2 3mod args; 4mod did; 5mod knot; 6 7fn main() -> Result<(), ()> { 8 // load configuration 9 let config = match args::load_config() { 10 Ok(res) => res, 11 Err(_) => return Err(()), 12 }; 13 14 // resolve handle to did 15 println!("Resolving {}", config.handle); 16 let did_doc = match did::get_did(&config.handle) { 17 Ok(res) => res, 18 Err(_) => return Err(()), 19 }; 20 println!( 21 " Found DID `{0}` hosted at `{1}`", 22 did_doc.did, did_doc.pds 23 ); 24 25 // resolve did+repoName to knotserver 26 println!("Resolving @{0}/{1}", config.handle, config.repo_name); 27 let knot_server = match knot::find_knot(&did_doc.did, &config.repo_name, &did_doc.pds) { 28 Ok(val) => val, 29 Err(_) => return Err(()), 30 }; 31 println!(" Found knot `{}`", knot_server); 32 33 // connect to /events on knotserver 34 println!( 35 "Connecting to `{}`", 36 format!("wss://{}/events", knot_server) 37 ); 38 let mut client = match ClientBuilder::new(&format!("wss://{}/events", knot_server)) { 39 Ok(mut val) => match val.connect(None) { 40 Ok(val) => val, 41 Err(_) => { 42 println!(" Couldn't open a connection"); 43 return Err(()); 44 } 45 }, 46 Err(_) => { 47 println!(" Knot server was malformed."); 48 return Err(()); 49 } 50 }; 51 println!(" Connected successfully."); 52 53 // on event: 54 // parse json 55 // validate meets expected schema (allow unknown vals) 56 // filter by did and reponame 57 // exec shell command in user shell (/bin/sh as fallback) 58 59 return Ok(()); 60}