Skip to content

Commit

Permalink
Do not sync VK contacts without contact details
Browse files Browse the repository at this point in the history
  • Loading branch information
Antti Seppälä committed Oct 12, 2015
1 parent 00d540e commit 5d6c35e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/vk/vk-contacts/vkcontactsyncadaptor.cpp
Expand Up @@ -581,6 +581,14 @@ QList<QContact> VKContactSyncAdaptor::parseContacts(const QJsonArray &json, int
const QJsonObject &obj((*it).toObject());
if (obj.isEmpty()) continue;

QString mobilePhone = obj.value("mobile_phone").toString();
QString homePhone = obj.value("home_phone").toString();

if (mobilePhone.isEmpty() && homePhone.isEmpty()) {
// no contact information, skip
continue;
}

// build the contact.
QContact c;

Expand Down Expand Up @@ -633,14 +641,14 @@ QList<QContact> VKContactSyncAdaptor::parseContacts(const QJsonArray &json, int
saveNonexportableDetail(c, addr);
}

if (!obj.value("mobile_phone").toString().isEmpty()) {
if (!mobilePhone.isEmpty()) {
QContactPhoneNumber num;
num.setSubTypes(QList<int>() << QContactPhoneNumber::SubTypeMobile);
num.setNumber(obj.value("mobile_phone").toString());
saveNonexportableDetail(c, num);
}

if (!obj.value("home_phone").toString().isEmpty()) {
if (!homePhone.isEmpty()) {
QContactPhoneNumber num;
num.setContexts(QContactDetail::ContextHome);
num.setSubTypes(QList<int>() << QContactPhoneNumber::SubTypeLandline);
Expand Down Expand Up @@ -708,6 +716,7 @@ void VKContactSyncAdaptor::transformContactAvatars(QList<QContact> &remoteContac
m_contactAvatars[accountId].insert(contactGuid, remoteImageUrl);
curr.removeDetail(&avatar);
// then trigger the download

queueAvatarForDownload(accountId, accessToken, contactGuid, remoteImageUrl);
}
}
Expand Down

0 comments on commit 5d6c35e

Please sign in to comment.