Skip to content
Snippets Groups Projects
Commit 82d2e902 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

conversation: contact added

- fix possible crash when trying to access uri of contact that
is not in the contact list
- save TEMPORARY contact after receiving daemon signal contact added

Change-Id: I55873c609717932b9e8ed94ed11f9f72b9db76c3
Gitlab: #431
parent 4f868983
No related branches found
No related tags found
No related merge requests found
......@@ -260,7 +260,8 @@ ContactModel::addContact(contact::Info contactInfo)
case profile::Type::TEMPORARY:
ConfigurationManager::instance().addContact(owner.id, profile.uri);
ConfigurationManager::instance().sendTrustRequest(owner.id, profile.uri, vCard);
break;
// will be saved after receiving contact added signal
return;
case profile::Type::PENDING:
if (daemon::addContactFromPending(owner, profile.uri)) {
emit pendingContactAccepted(profile.uri);
......@@ -293,8 +294,6 @@ ContactModel::addContact(contact::Info contactInfo)
iter->profileInfo = contactInfo.profileInfo;
}
}
if (profile.type == profile::Type::TEMPORARY)
return;
emit contactAdded(profile.uri);
}
......@@ -618,13 +617,14 @@ ContactModelPimpl::slotContactAdded(const QString& accountId, const QString& con
{
if (accountId != linked.owner.id) return;
auto contact = contacts.find(contactUri);
if (contact->profileInfo.type == profile::Type::PENDING) {
emit behaviorController.trustRequestTreated(linked.owner.id, contactUri);
} else if (contact->profileInfo.type == profile::Type::RING && !contact->isBanned && confirmed) {
// This means that the peer accepted the trust request. We don't need to re-add the contact
// a second time (and this reset the presence to false).
return;
if (contact != contacts.end()) {
if (contact->profileInfo.type == profile::Type::PENDING) {
emit behaviorController.trustRequestTreated(linked.owner.id, contactUri);
} else if (contact->profileInfo.type == profile::Type::RING && !contact->isBanned && confirmed) {
// This means that the peer accepted the trust request. We don't need to re-add the contact
// a second time (and this reset the presence to false).
return;
}
}
bool isBanned = false;
......@@ -636,7 +636,7 @@ ContactModelPimpl::slotContactAdded(const QString& accountId, const QString& con
{
// Check whether contact is banned or not
std::lock_guard<std::mutex> lk(bannedContactsMtx_);
auto it = std::find(bannedContacts.begin(), bannedContacts.end(), contact->profileInfo.uri);
auto it = std::find(bannedContacts.begin(), bannedContacts.end(), contactUri);
isBanned = (it != bannedContacts.end());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment