diff options
Diffstat (limited to 'protocols/Discord/src')
-rw-r--r-- | protocols/Discord/src/proto.cpp | 14 | ||||
-rw-r--r-- | protocols/Discord/src/stdafx.h | 2 |
2 files changed, 13 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); diff --git a/protocols/Discord/src/stdafx.h b/protocols/Discord/src/stdafx.h index 7e04081d2c..acf9ec0dfc 100644 --- a/protocols/Discord/src/stdafx.h +++ b/protocols/Discord/src/stdafx.h @@ -16,6 +16,8 @@ #include <direct.h> #include <time.h> +#include <vector> + #include "resource.h" #include <m_system.h> |