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
Branches
Tags
No related merge requests found
...@@ -260,7 +260,8 @@ ContactModel::addContact(contact::Info contactInfo) ...@@ -260,7 +260,8 @@ ContactModel::addContact(contact::Info contactInfo)
case profile::Type::TEMPORARY: case profile::Type::TEMPORARY:
ConfigurationManager::instance().addContact(owner.id, profile.uri); ConfigurationManager::instance().addContact(owner.id, profile.uri);
ConfigurationManager::instance().sendTrustRequest(owner.id, profile.uri, vCard); ConfigurationManager::instance().sendTrustRequest(owner.id, profile.uri, vCard);
break; // will be saved after receiving contact added signal
return;
case profile::Type::PENDING: case profile::Type::PENDING:
if (daemon::addContactFromPending(owner, profile.uri)) { if (daemon::addContactFromPending(owner, profile.uri)) {
emit pendingContactAccepted(profile.uri); emit pendingContactAccepted(profile.uri);
...@@ -293,8 +294,6 @@ ContactModel::addContact(contact::Info contactInfo) ...@@ -293,8 +294,6 @@ ContactModel::addContact(contact::Info contactInfo)
iter->profileInfo = contactInfo.profileInfo; iter->profileInfo = contactInfo.profileInfo;
} }
} }
if (profile.type == profile::Type::TEMPORARY)
return;
emit contactAdded(profile.uri); emit contactAdded(profile.uri);
} }
...@@ -618,7 +617,7 @@ ContactModelPimpl::slotContactAdded(const QString& accountId, const QString& con ...@@ -618,7 +617,7 @@ ContactModelPimpl::slotContactAdded(const QString& accountId, const QString& con
{ {
if (accountId != linked.owner.id) return; if (accountId != linked.owner.id) return;
auto contact = contacts.find(contactUri); auto contact = contacts.find(contactUri);
if (contact != contacts.end()) {
if (contact->profileInfo.type == profile::Type::PENDING) { if (contact->profileInfo.type == profile::Type::PENDING) {
emit behaviorController.trustRequestTreated(linked.owner.id, contactUri); emit behaviorController.trustRequestTreated(linked.owner.id, contactUri);
} else if (contact->profileInfo.type == profile::Type::RING && !contact->isBanned && confirmed) { } else if (contact->profileInfo.type == profile::Type::RING && !contact->isBanned && confirmed) {
...@@ -626,6 +625,7 @@ ContactModelPimpl::slotContactAdded(const QString& accountId, const QString& con ...@@ -626,6 +625,7 @@ ContactModelPimpl::slotContactAdded(const QString& accountId, const QString& con
// a second time (and this reset the presence to false). // a second time (and this reset the presence to false).
return; return;
} }
}
bool isBanned = false; bool isBanned = false;
...@@ -636,7 +636,7 @@ ContactModelPimpl::slotContactAdded(const QString& accountId, const QString& con ...@@ -636,7 +636,7 @@ ContactModelPimpl::slotContactAdded(const QString& accountId, const QString& con
{ {
// Check whether contact is banned or not // Check whether contact is banned or not
std::lock_guard<std::mutex> lk(bannedContactsMtx_); 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()); isBanned = (it != bannedContacts.end());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment