diff options
author | George Hazan <ghazan@miranda.im> | 2018-10-01 15:36:26 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-10-01 15:36:26 +0300 |
commit | e808179197e8875f3faa85ad8f0d1e75d756716f (patch) | |
tree | 6ca118531ebf3d2d85a0123171298e74b2decbd6 /protocols/Discord/src | |
parent | 966214ad3db583c8e8cbfbae4281705f73df4429 (diff) |
centralized system of processing message ids. also fixes #1375
Diffstat (limited to 'protocols/Discord/src')
-rw-r--r-- | protocols/Discord/src/dispatch.cpp | 8 | ||||
-rw-r--r-- | protocols/Discord/src/proto.cpp | 14 | ||||
-rw-r--r-- | protocols/Discord/src/proto.h | 9 |
3 files changed, 11 insertions, 20 deletions
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index 2ee6930721..dbb30f382c 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -316,7 +316,8 @@ void CDiscordProto::OnCommandMessage(const JSONNode &pRoot) CMStringW wszMessageId = pRoot["id"].as_mstring(); CMStringW wszUserId = pRoot["author"]["id"].as_mstring(); SnowFlake userId = _wtoi64(wszUserId); - CDiscordMessage msg(_wtoi64(wszMessageId), userId); + SnowFlake msgId = _wtoi64(wszMessageId); + CDiscordMessage msg(msgId, userId); // try to find a sender by his channel SnowFlake channelId = ::getId(pRoot["channel_id"]); @@ -350,9 +351,12 @@ void CDiscordProto::OnCommandMessage(const JSONNode &pRoot) debugLogA("store a message from private user %lld, channel id %lld", pUser->id, pUser->channelId); ptrA buf(mir_utf8encodeW(wszText)); + char szMsgId[100]; + _i64toa_s(msgId, szMsgId, _countof(szMsgId), 10); + recv.timestamp = (DWORD)StringToDate(pRoot["timestamp"].as_mstring()); recv.szMessage = buf; - recv.lParam = (LPARAM)wszMessageId.c_str(); + recv.szMsgId = szMsgId; ProtoChainRecvMsg(pUser->hContact, &recv); } else { diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index 386f9c8844..574bd2be53 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -145,7 +145,7 @@ INT_PTR CDiscordProto::GetCaps(int type, MCONTACT) case PFLAGNUM_3: return PF2_ONLINE | PF2_LONGAWAY | PF2_HEAVYDND | PF2_INVISIBLE; case PFLAGNUM_4: - return PF4_FORCEADDED | PF4_FORCEAUTH | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_SUPPORTIDLE | PF4_AVATARS | PF4_IMSENDOFFLINE; + return PF4_FORCEADDED | PF4_FORCEAUTH | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_SUPPORTIDLE | PF4_AVATARS | PF4_IMSENDOFFLINE | PF4_SERVERMSGID; case PFLAG_UNIQUEIDTEXT: return (INT_PTR)Translate("User ID"); } @@ -351,18 +351,6 @@ MCONTACT CDiscordProto::AddToList(int flags, PROTOSEARCHRESULT *psr) } //////////////////////////////////////////////////////////////////////////////////////// -// RecvMsg - -MEVENT CDiscordProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *evt) -{ - MEVENT hDbEvent = CSuper::RecvMsg(hContact, evt); - if (hDbEvent && evt->lParam) - db_event_setId(m_szModuleName, hDbEvent, T2Utf((const wchar_t*)evt->lParam)); - - return hDbEvent; -} - -//////////////////////////////////////////////////////////////////////////////////////// // SendMsg void __cdecl CDiscordProto::SendMessageAckThread(void *param) diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index 878b054e6f..7874a8ffb6 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -265,16 +265,15 @@ public: HWND CreateExtendedSearchUI(HWND owner) override; HWND SearchAdvanced(HWND owner) override; - HANDLE SearchBasic(const wchar_t* id) override; - MCONTACT AddToList(int flags, PROTOSEARCHRESULT* psr) override; + HANDLE SearchBasic(const wchar_t *id) override; + MCONTACT AddToList(int flags, PROTOSEARCHRESULT *psr) override; - int AuthRecv(MCONTACT, PROTORECVEVENT* pre) override; + int AuthRecv(MCONTACT, PROTORECVEVENT *pre) override; int Authorize(MEVENT hDbEvent) override; int AuthDeny(MEVENT hDbEvent, const wchar_t* szReason) override; int AuthRequest(MCONTACT hContact, const wchar_t*) override; - MEVENT RecvMsg(MCONTACT hContact, PROTORECVEVENT *evt) override; - int SendMsg(MCONTACT hContact, int flags, const char* pszSrc) override; + int SendMsg(MCONTACT hContact, int flags, const char *pszSrc) override; HANDLE SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles) override; |