From 970e53304c51a634e3b3b85640fa6e16bfceea8f Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 21 Apr 2022 20:36:34 -0700 Subject: [PATCH] accept fixes --- Cargo.lock | 4 +++- src/main.rs | 19 ++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7049b92..3a7710a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -131,7 +131,9 @@ checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" [[package]] name = "libcwtch" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25c487f128e73d0c8a18f421f67efa7cf0b3ee913dbd2b1ef49b0854e25abf85" dependencies = [ "hex-literal", "libc", diff --git a/src/main.rs b/src/main.rs index be33855..d306371 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,10 +93,7 @@ impl UpdateBot { Some(last_offered) => last_offered != self.version, None => true, }, - Err(e) => { - println!("Error parsing attribute: {}", e); - false - } + Err(e) => false }; if do_offer { self.offer(cwtch, profile_opt, convo_id); @@ -132,18 +129,18 @@ impl imp::EventHandler for UpdateBot { let event_type = Event::from(event.event_type.as_str()); match event_type { Event::ContactCreated => { - if event.data["ConnectionState"] == "Authenticated" { - let convo_id = event.data["ConversationID"].parse::().unwrap(); - self.greet(cwtch, profile_opt, convo_id); - } + let convo_id = event.data["ConversationID"].parse::().unwrap(); + self.greet(cwtch, profile_opt, convo_id); } Event::PeerStateChange => { if event.data["ConnectionState"] == "Authenticated" { match profile_opt.as_ref() { Some(profile) => { - let conversation = - &profile.conversations[&event.data["RemotePeer"]]; - self.greet(cwtch, profile_opt, conversation.identifier); + if profile.conversations.contains_key(&event.data["RemotePeer"]) { + let conversation = + &profile.conversations[&event.data["RemotePeer"]]; + self.greet(cwtch, profile_opt, conversation.identifier); + } } None => (), };