diff options
author | George Hazan <ghazan@miranda.im> | 2020-12-07 10:20:29 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-12-07 10:20:29 +0300 |
commit | 8a557bb6c7119e9a8d196d76e144727b1b861c1d (patch) | |
tree | a99630276d5686f6e7efa01ad0fc7d6e5f99bae7 /protocols/Discord/src/proto.cpp | |
parent | 616c71ae4bbe9197bbb3ee055801d18ed0ab44e8 (diff) |
Discord: fix for a possible contact duplication
Diffstat (limited to 'protocols/Discord/src/proto.cpp')
-rw-r--r-- | protocols/Discord/src/proto.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index 898f30ff8b..27cf9b4cf6 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -134,6 +134,8 @@ CDiscordProto::~CDiscordProto() void CDiscordProto::OnModulesLoaded() { + std::vector<MCONTACT> lostIds; + // Fill users list for (auto &hContact : AccContacts()) { CDiscordUser *pNew = new CDiscordUser(getId(hContact, DB_KEY_ID)); @@ -141,7 +143,6 @@ void CDiscordProto::OnModulesLoaded() pNew->lastMsgId = getId(hContact, DB_KEY_LASTMSGID); pNew->wszUsername = ptrW(getWStringA(hContact, DB_KEY_NICK)); pNew->iDiscriminator = getDword(hContact, DB_KEY_DISCR); - arUsers.insert(pNew); // set EnableSync = 1 by default for all existing guilds switch (getByte(hContact, "ChatRoom")) { @@ -153,16 +154,23 @@ void CDiscordProto::OnModulesLoaded() case 1: // group chat pNew->channelId = getId(hContact, DB_KEY_CHANNELID); - if (!pNew->channelId) - db_delete_contact(hContact); + if (!pNew->channelId) { + lostIds.push_back(hContact); + delete pNew; + continue; + } break; default: pNew->channelId = getId(hContact, DB_KEY_CHANNELID); break; } + arUsers.insert(pNew); } + for (auto &hContact: lostIds) + db_delete_contact(hContact); + // Clist Clist_GroupCreate(0, m_wszDefaultGroup); |