From d0feef929e7a4432db63af44a9f99409ebbe4a10 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 16 Mar 2021 20:19:11 +0300 Subject: Skype: fix for creating duplicate contacts running newly created account for the first time --- protocols/SkypeWeb/src/skype_contacts.cpp | 84 +++++++++++++++---------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'protocols') diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index 89a62fad67..4adb73e341 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -154,61 +154,61 @@ void CSkypeProto::LoadContactList(NETLIBHTTPREQUEST *response, AsyncHttpRequest* for (auto &item : root["contacts"]) { const JSONNode &name = item["name"]; - std::string skypeId = item["id"].as_string(); + std::string skypeId = item["person_id"].as_string(); CMStringW first_name = name["first"].as_mstring(); CMStringW last_name = name["surname"].as_mstring(); CMStringW avatar_url = item["avatar_url"].as_mstring(); std::string type = item["type"].as_string(); if (type == "skype" || loadAll) { - std::string displayName = item["displayname"].as_string(); - const char *szNick = (displayName.empty()) ? nullptr : displayName.c_str(); - - MCONTACT hContact = AddContact(skypeId.c_str(), szNick); - if (hContact) { - if (item["authorized"].as_bool()) { - delSetting(hContact, "Auth"); - delSetting(hContact, "Grant"); - } - else setByte(hContact, "Grant", 1); - - if (item["blocked"].as_bool()) - setByte(hContact, "IsBlocked", 1); - else - delSetting(hContact, "IsBlocked"); - - ptrW wszGroup(Clist_GetGroup(hContact)); - if (wszGroup == nullptr) { - if (wstrCListGroup) { - Clist_GroupCreate(0, wstrCListGroup); - Clist_SetGroup(hContact, wstrCListGroup); - } + MCONTACT hContact = AddContact(skypeId.c_str(), nullptr); + + std::string displayName = item["display_name"].as_string(); + if (!displayName.empty()) + setUString(hContact, "Nick", displayName.c_str()); + + if (item["authorized"].as_bool()) { + delSetting(hContact, "Auth"); + delSetting(hContact, "Grant"); + } + else setByte(hContact, "Grant", 1); + + if (item["blocked"].as_bool()) + setByte(hContact, "IsBlocked", 1); + else + delSetting(hContact, "IsBlocked"); + + ptrW wszGroup(Clist_GetGroup(hContact)); + if (wszGroup == nullptr) { + if (wstrCListGroup) { + Clist_GroupCreate(0, wstrCListGroup); + Clist_SetGroup(hContact, wstrCListGroup); } + } - setString(hContact, "Type", type.c_str()); + setString(hContact, "Type", type.c_str()); - if (first_name) - setWString(hContact, "FirstName", first_name); - if (last_name) - setWString(hContact, "LastName", last_name); + if (first_name) + setWString(hContact, "FirstName", first_name); + if (last_name) + setWString(hContact, "LastName", last_name); - if (item["mood"]) - db_set_ws(hContact, "CList", "StatusMsg", RemoveHtml(item["mood"].as_mstring())); + if (item["mood"]) + db_set_ws(hContact, "CList", "StatusMsg", RemoveHtml(item["mood"].as_mstring())); - SetAvatarUrl(hContact, avatar_url); - ReloadAvatarInfo(hContact); + SetAvatarUrl(hContact, avatar_url); + ReloadAvatarInfo(hContact); - for (auto &phone : item["phones"]) { - CMStringW number = phone["number"].as_mstring(); + for (auto &phone : item["phones"]) { + CMStringW number = phone["number"].as_mstring(); - switch (phone["type"].as_int()) { - case 0: - setWString(hContact, "Phone", number); - break; - case 2: - setWString(hContact, "Cellular", number); - break; - } + switch (phone["type"].as_int()) { + case 0: + setWString(hContact, "Phone", number); + break; + case 2: + setWString(hContact, "Cellular", number); + break; } } } -- cgit v1.2.3