diff options
author | George Hazan <ghazan@miranda.im> | 2020-12-06 20:34:57 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-12-06 20:34:57 +0300 |
commit | 616c71ae4bbe9197bbb3ee055801d18ed0ab44e8 (patch) | |
tree | afd947078b18a0538b584c6749ccd08ceeed63a6 /protocols/Discord/src/guilds.cpp | |
parent | e63fd013199b9b3d411b304459d9a964f42756f5 (diff) |
Discord: fix for retrieving groupchat history again & again
Diffstat (limited to 'protocols/Discord/src/guilds.cpp')
-rw-r--r-- | protocols/Discord/src/guilds.cpp | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp index 9b360d8bc8..58a8b29651 100644 --- a/protocols/Discord/src/guilds.cpp +++ b/protocols/Discord/src/guilds.cpp @@ -117,6 +117,16 @@ void CDiscordProto::CreateChat(CDiscordGuild *pGuild, CDiscordUser *pUser) SESSION_INFO *si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, pUser->wszUsername, pUser->wszChannelName); si->pParent = pGuild->pParentSi; pUser->hContact = si->hContact; + setId(pUser->hContact, DB_KEY_ID, pUser->channelId); + setId(pUser->hContact, DB_KEY_CHANNELID, pUser->channelId); + + SnowFlake oldMsgId = getId(pUser->hContact, DB_KEY_LASTMSGID); + if (oldMsgId == 0) + RetrieveHistory(pUser, MSG_BEFORE, pUser->lastMsgId, 20); + else if (!pUser->bSynced && pUser->lastMsgId > oldMsgId) { + pUser->bSynced = true; + RetrieveHistory(pUser, MSG_AFTER, oldMsgId, 99); + } if (m_bUseGuildGroups) { if (pUser->parentId) { @@ -218,19 +228,6 @@ void CDiscordProto::ProcessGuild(const JSONNode &pRoot) if (m_bUseGroupchats) ForkThread(&CDiscordProto::BatchChatCreate, pGuild); - // retrieve missing histories - for (auto &it : pGuild->arChannels) { - if (it->bIsPrivate) - continue; - - if (!it->bSynced) { - it->bSynced = true; - SnowFlake oldMsgId = getId(it->hContact, DB_KEY_LASTMSGID); - if (oldMsgId != 0 && it->lastMsgId > oldMsgId) - RetrieveHistory(it, MSG_AFTER, oldMsgId, 99); - } - } - pGuild->bSynced = true; } @@ -287,17 +284,6 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS pUser->pGuild = pGuild; pUser->lastMsgId = ::getId(pch["last_message_id"]); pUser->parentId = _wtoi64(pch["parent_id"].as_mstring()); - - SnowFlake oldMsgId = getId(pUser->hContact, DB_KEY_LASTMSGID); - if (oldMsgId == 0) - RetrieveHistory(pUser, MSG_BEFORE, pUser->lastMsgId, 20); - else if (!pUser->bSynced && pUser->lastMsgId > oldMsgId) { - pUser->bSynced = true; - RetrieveHistory(pUser, MSG_AFTER, oldMsgId, 99); - } - - setId(pUser->hContact, DB_KEY_ID, channelId); - setId(pUser->hContact, DB_KEY_CHANNELID, channelId); return pUser; } |