From b58bd0a705dba9a32e4db1420e2d615c6ee6bd41 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 10 Jan 2025 15:28:20 +0300 Subject: =?UTF-8?q?fixes=20#4830=20(SkypeWeb:=20=D1=80=D0=B5=D0=B4=D0=B0?= =?UTF-8?q?=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D0=BE?= =?UTF-8?q?=D0=B5=20=D1=81=D0=B2=D0=BE=D1=91=20=D1=81=D0=BE=D0=BE=D0=B1?= =?UTF-8?q?=D1=89=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B8=D1=85=D0=BE?= =?UTF-8?q?=D0=B4=D0=B8=D1=82=20=D0=BA=D0=B0=D0=BA=20=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BE=D0=B5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/SkypeWeb/src/skype_messages.cpp | 38 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_messages.cpp') diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index d9621c839a..d944390d5e 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -43,25 +43,24 @@ void CSkypeProto::OnMessageSent(MHttpResponse *response, AsyncHttpRequest *pRequ } // outcoming message flow + int CSkypeProto::SendMsg(MCONTACT hContact, MEVENT, const char *szMessage) { if (!IsOnline()) return -1; - uint32_t hMessage; - Utils_GetRandom(&hMessage, sizeof(hMessage)); - hMessage &= ~0x80000000; - CMStringA str(szMessage); bool bRich = AddBbcodes(str); + int64_t iRandomId = getRandomId(); + m_iMessageId++; CMStringA szUrl = "/users/ME/conversations/" + mir_urlEncode(getId(hContact)) + "/messages"; AsyncHttpRequest *pReq = new AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, szUrl, &CSkypeProto::OnMessageSent); pReq->hContact = hContact; - pReq->pUserInfo = (HANDLE)hMessage; + pReq->pUserInfo = (HANDLE)m_iMessageId; JSONNode node; - node << INT64_PARAM("clientmessageid", hMessage) << CHAR_PARAM("messagetype", bRich ? "RichText" : "Text") << CHAR_PARAM("contenttype", "text"); + node << INT64_PARAM("clientmessageid", iRandomId) << CHAR_PARAM("messagetype", bRich ? "RichText" : "Text") << CHAR_PARAM("contenttype", "text"); if (strncmp(str, "/me ", 4) == 0) node << CHAR_PARAM("content", m_szSkypename + " " + str); else @@ -71,8 +70,8 @@ int CSkypeProto::SendMsg(MCONTACT hContact, MEVENT, const char *szMessage) PushRequest(pReq); mir_cslock lck(m_lckOutMessagesList); - m_OutMessages.insert((void*)hMessage); - return hMessage; + m_OutMessages.insert(new COwnMessage(m_iMessageId, iRandomId)); + return m_iMessageId; } // preparing message/action to be written into db @@ -120,15 +119,15 @@ LBL_Deleted: } if (strMessageType == "Text" || strMessageType == "RichText") { - std::string szOwnMessageId = node["clientmessageid"].as_string(); - if ((dbei.flags & DBEF_SENT) && !szOwnMessageId.empty()) { - HANDLE hMessage = (HANDLE)atoi(szOwnMessageId.c_str()); - if (m_OutMessages.getIndex(hMessage) != -1) { - ProtoBroadcastAck(dbei.hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, hMessage, (LPARAM)dbei.szId); - - mir_cslock lck(m_lckOutMessagesList); - m_OutMessages.remove(hMessage); - return false; + if ((dbei.flags & DBEF_SENT) && dbei.szId) { + for (auto &it: m_OutMessages) { + if (it->hClientMessageId == _atoi64(dbei.szId)) { + ProtoBroadcastAck(dbei.hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)it->hMessage, (LPARAM)dbei.szId); + + mir_cslock lck(m_lckOutMessagesList); + m_OutMessages.removeItem(&it); + return false; + } } } @@ -163,7 +162,8 @@ void CSkypeProto::ProcessNewMessage(const JSONNode &node) int iUserType; UrlToSkypeId(node["conversationLink"].as_string().c_str(), &iUserType); - CMStringA szMessageId = node["id"].as_mstring(); + CMStringA szId = node["id"].as_mstring(); + CMStringA szMessageId(getMessageId(node)); CMStringA szConversationName(UrlToSkypeId(node["conversationLink"].as_string().c_str())); CMStringA szFromSkypename(UrlToSkypeId(node["from"].as_mstring())); @@ -174,7 +174,7 @@ void CSkypeProto::ProcessNewMessage(const JSONNode &node) MCONTACT hContact = AddContact(szConversationName, nullptr, true); if (m_bHistorySynced) { - int64_t lastMsgId = _atoi64(szMessageId); + int64_t lastMsgId = _atoi64(szId); if (lastMsgId > getLastTime(hContact)) setLastTime(hContact, lastMsgId); } -- cgit v1.2.3