fixes
This commit is contained in:
parent
e8f9088c85
commit
e64351f6b8
36
src/imp.rs
36
src/imp.rs
|
@ -145,7 +145,6 @@ impl Imp {
|
|||
Ok(p) => p,
|
||||
Err(e) => panic!("error parsing profile: {}", e),
|
||||
};
|
||||
print!("profile: {:?}", profile);
|
||||
// Share profile image
|
||||
match self.settings.as_ref() {
|
||||
Some(_settings) => {
|
||||
|
@ -156,6 +155,17 @@ impl Imp {
|
|||
|
||||
self.cwtch.set_profile_attribute(&profile.handle, "profile.name", &self.behaviour.profile_name);
|
||||
|
||||
for (_id, conversation) in &profile.conversations {
|
||||
match self.behaviour.default_contant_policy {
|
||||
DefaultContactPolicy::Accept => {
|
||||
self.cwtch.accept_conversation(&profile.handle.clone(), conversation.identifier);
|
||||
},
|
||||
DefaultContactPolicy::Block =>
|
||||
self.cwtch.block_contact(&profile.handle.clone(), conversation.identifier),
|
||||
DefaultContactPolicy::Ignore => (),
|
||||
}
|
||||
}
|
||||
|
||||
self.profile = Some(profile);
|
||||
}
|
||||
Event::AppError => {
|
||||
|
@ -164,15 +174,15 @@ impl Imp {
|
|||
}
|
||||
}
|
||||
Event::ContactCreated => {
|
||||
if event.data["ConnectionState"] == "Authenticated" {
|
||||
let profile_onion = event.data["RemotePeer"].to_string();
|
||||
println!("Contact Created");
|
||||
let convo_handle = event.data["RemotePeer"].to_string();
|
||||
let convo_id = event.data["ConversationID"].parse::<i32>().unwrap();
|
||||
|
||||
let acl: ACL = serde_json::from_str(&event.data["accessControlList"])
|
||||
.expect("Error parsing conversation");
|
||||
|
||||
let conversation = Conversation {
|
||||
handle: profile_onion.clone(),
|
||||
handle: convo_handle.clone(),
|
||||
identifier: event.data["ConversationID"].parse::<i32>().unwrap(),
|
||||
name: event.data["nick"].to_string(),
|
||||
status: ConnectionState::new(&event.data["status"]),
|
||||
|
@ -182,23 +192,25 @@ impl Imp {
|
|||
is_group: false, // by definition
|
||||
};
|
||||
|
||||
match self.behaviour.default_contant_policy {
|
||||
DefaultContactPolicy::Accept =>
|
||||
self.cwtch.accept_conversation(&conversation.handle.clone(), convo_id),
|
||||
DefaultContactPolicy::Block =>
|
||||
self.cwtch.block_contact(&conversation.handle.clone(), convo_id),
|
||||
DefaultContactPolicy::Ignore => (),
|
||||
}
|
||||
|
||||
match self.profile.as_mut() {
|
||||
Some(profile) => {
|
||||
profile
|
||||
.conversations
|
||||
.insert(event.data["RemotePeer"].to_string(), conversation);
|
||||
|
||||
match self.behaviour.default_contant_policy {
|
||||
DefaultContactPolicy::Accept => {
|
||||
self.cwtch.accept_conversation(&profile.handle.clone(), convo_id);
|
||||
},
|
||||
DefaultContactPolicy::Block =>
|
||||
self.cwtch.block_contact(&profile.handle.clone(), convo_id),
|
||||
DefaultContactPolicy::Ignore => (),
|
||||
}
|
||||
}
|
||||
None => (),
|
||||
};
|
||||
}
|
||||
Event::PeerStateChange => {
|
||||
}
|
||||
Event::ErrUnhandled(err) => eprintln!("unhandled event: {}!", err),
|
||||
_ => (),
|
||||
|
|
Loading…
Reference in New Issue