diff options
author | George Hazan <ghazan@miranda.im> | 2019-03-08 15:02:00 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-03-08 15:02:00 +0300 |
commit | a23186175cff579d5aeb231372e87b0b852bdb38 (patch) | |
tree | 7c9cb784d67e80851ecfd6a21d4d038f3ff0c5c4 /protocols | |
parent | 294e9e5bc47f80e61b701b1ecb748b5e8100e465 (diff) |
fixes #1863 completely ([Discord] add manual history sync from IMs/DMs (private chat))
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Discord/src/menus.cpp | 29 | ||||
-rw-r--r-- | protocols/Discord/src/proto.h | 2 | ||||
-rw-r--r-- | protocols/Discord/src/server.cpp | 13 | ||||
-rw-r--r-- | protocols/Discord/src/version.h | 2 |
4 files changed, 37 insertions, 9 deletions
diff --git a/protocols/Discord/src/menus.cpp b/protocols/Discord/src/menus.cpp index 88404bd782..fc3df4d44e 100644 --- a/protocols/Discord/src/menus.cpp +++ b/protocols/Discord/src/menus.cpp @@ -76,6 +76,19 @@ INT_PTR CDiscordProto::OnMenuLeaveGuild(WPARAM hContact, LPARAM) ///////////////////////////////////////////////////////////////////////////////////////// +INT_PTR CDiscordProto::OnMenuLoadHistory(WPARAM hContact, LPARAM) +{ + auto *pUser = FindUser(getId(hContact, DB_KEY_ID)); + if (pUser) { + pUser->bSkipHistory = true; + RetrieveHistory(pUser, MSG_AFTER, 0, 100); + pUser->bSkipHistory = false; + } + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + INT_PTR CDiscordProto::OnMenuToggleSync(WPARAM hContact, LPARAM) { bool bEnabled = !getBool(hContact, "EnableSync"); @@ -133,34 +146,42 @@ void CDiscordProto::InitMenus() CMenuItem mi2(&g_plugin); mi2.pszService = "/LeaveGuild"; CreateProtoService(mi2.pszService, &CDiscordProto::OnMenuLeaveGuild); + SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8C); mi2.name.a = LPGEN("Leave guild"); mi2.position = -200001000; mi2.hIcolibItem = Skin_GetIconHandle(SKINICON_CHAT_LEAVE); - SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8C); m_hMenuLeaveGuild = Menu_AddContactMenuItem(&mi2, m_szModuleName); mi2.pszService = "/CreateChannel"; CreateProtoService(mi2.pszService, &CDiscordProto::OnMenuCreateChannel); + SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8D); mi2.name.a = LPGEN("Create new channel"); mi2.position = -200001001; mi2.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_ADDCONTACT); - SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8D); m_hMenuCreateChannel = Menu_AddContactMenuItem(&mi2, m_szModuleName); + SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8E); mi2.pszService = "/CopyId"; mi2.name.a = LPGEN("Copy Discord ID"); mi2.position = -200001002; mi2.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_USERONLINE); - SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8E); Menu_AddContactMenuItem(&mi2, m_szModuleName); mi2.pszService = "/ToggleSync"; CreateProtoService(mi2.pszService, &CDiscordProto::OnMenuToggleSync); + SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8F); mi2.name.a = LPGEN("Enable guild"); mi2.position = -200001003; mi2.hIcolibItem = Skin_GetIconHandle(SKINICON_CHAT_JOIN); - SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8F); m_hMenuToggleSync = Menu_AddContactMenuItem(&mi2, m_szModuleName); + mi2.pszService = "/LoadHistory"; + CreateProtoService(mi2.pszService, &CDiscordProto::OnMenuLoadHistory); + SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x90); + mi2.name.a = LPGEN("Load server history"); + mi2.position = -200001004; + mi2.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_HISTORY); + Menu_AddContactMenuItem(&mi2, m_szModuleName); + HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CDiscordProto::OnMenuPrebuild); } diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index 873287bc1c..611db0d662 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -65,6 +65,7 @@ struct CDiscordUser : public MZeroedObject SnowFlake parentId; bool bIsPrivate; bool bIsGroup; + bool bSkipHistory; struct CDiscordGuild *pGuild; @@ -209,6 +210,7 @@ class CDiscordProto : public PROTO<CDiscordProto> INT_PTR __cdecl OnMenuCreateChannel(WPARAM, LPARAM); INT_PTR __cdecl OnMenuJoinGuild(WPARAM, LPARAM); INT_PTR __cdecl OnMenuLeaveGuild(WPARAM, LPARAM); + INT_PTR __cdecl OnMenuLoadHistory(WPARAM, LPARAM); INT_PTR __cdecl OnMenuToggleSync(WPARAM, LPARAM); HGENMENU m_hMenuLeaveGuild, m_hMenuCreateChannel, m_hMenuToggleSync; diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index 661e313290..cae684f970 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -109,10 +109,15 @@ void CDiscordProto::OnReceiveHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest char szMsgId[100]; _i64toa_s(msgid, szMsgId, _countof(szMsgId), 10); MEVENT hDbEvent = db_event_getById(m_szModuleName, szMsgId); - if (hDbEvent != 0) - db_event_edit(pUser->hContact, hDbEvent, &dbei); - else - db_event_add(pUser->hContact, &dbei); + if (hDbEvent != 0) { + if (!pUser->bSkipHistory) + db_event_edit(pUser->hContact, hDbEvent, &dbei); + } + else { + MEVENT hNew = db_event_add(pUser->hContact, &dbei); + if (hNew != 0) + db_event_setId(m_szModuleName, hNew, szMsgId); + } } else { ParseSpecialChars(si, wszText); diff --git a/protocols/Discord/src/version.h b/protocols/Discord/src/version.h index da2758b1c2..61ad77e877 100644 --- a/protocols/Discord/src/version.h +++ b/protocols/Discord/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 6 #define __RELEASE_NUM 1 -#define __BUILD_NUM 3 +#define __BUILD_NUM 4 #include <stdver.h> |