accept fixes

This commit is contained in:
Dan Ballard 2022-04-21 20:36:34 -07:00
parent 0cabdde59a
commit 970e53304c
2 changed files with 11 additions and 12 deletions

4
Cargo.lock generated
View File

@ -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",

View File

@ -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::<i32>().unwrap();
self.greet(cwtch, profile_opt, convo_id);
}
let convo_id = event.data["ConversationID"].parse::<i32>().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 => (),
};