diff options
author | George Hazan <george.hazan@gmail.com> | 2025-04-24 18:37:06 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2025-04-24 18:37:06 +0300 |
commit | d8ef7ec807a4a517896ead1e98f366f06b29c76a (patch) | |
tree | ef19ef16a8b38db0d063ef6d0e743dea15b10a8c | |
parent | 53e0b5f3ff938adf11b2237727510e07e23ffdb6 (diff) |
Teams: fix for sending messages to group chats
-rw-r--r-- | protocols/Teams/src/teams_chatrooms.cpp | 9 | ||||
-rw-r--r-- | protocols/Teams/src/teams_messages.cpp | 18 | ||||
-rw-r--r-- | protocols/Teams/src/teams_proto.h | 7 |
3 files changed, 25 insertions, 9 deletions
diff --git a/protocols/Teams/src/teams_chatrooms.cpp b/protocols/Teams/src/teams_chatrooms.cpp index d2ee2fa99e..436a3a196b 100644 --- a/protocols/Teams/src/teams_chatrooms.cpp +++ b/protocols/Teams/src/teams_chatrooms.cpp @@ -336,16 +336,17 @@ void CTeamsProto::SendChatMessage(SESSION_INFO *si, const wchar_t *tszMessage) szMessage.TrimRight(); bool bRich = AddBbcodes(szMessage); - CMStringA szUrl = "/users/ME/conversations/" + mir_urlEncode(T2Utf(si->ptszID)) + "/messages"; - AsyncHttpRequest *pReq = new AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, szUrl, &CTeamsProto::OnMessageSent); - JSONNode node; node << INT64_PARAM("clientmessageid", getRandomId()) << CHAR_PARAM("messagetype", bRich ? "RichText" : "Text") << CHAR_PARAM("contenttype", "text") << CHAR_PARAM("content", szMessage); if (strncmp(szMessage, "/me ", 4) == 0) node << INT_PARAM("skypeemoteoffset", 4); + + CMStringA szUrl = "/users/ME/conversations/" + mir_urlEncode(T2Utf(si->ptszID)) + "/messages"; + AsyncHttpRequest *pReq = new AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, szUrl, &CTeamsProto::OnMessageSent); pReq->m_szParam = node.write().c_str(); - + pReq->pUserInfo = new COwnMessage(szMessage); + pReq->hContact = si->hContact; PushRequest(pReq); } diff --git a/protocols/Teams/src/teams_messages.cpp b/protocols/Teams/src/teams_messages.cpp index 9c29ee3827..4b3a0a96da 100644 --- a/protocols/Teams/src/teams_messages.cpp +++ b/protocols/Teams/src/teams_messages.cpp @@ -26,9 +26,6 @@ void CTeamsProto::OnMessageSent(MHttpResponse *response, AsyncHttpRequest *pRequ std::unique_ptr<COwnMessage> pMessage((COwnMessage *)pRequest->pUserInfo); MCONTACT hContact = pRequest->hContact; - if (Contact::IsGroupChat(hContact)) - return; - if (response == nullptr) { ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, pRequest->pUserInfo, (LPARAM)TranslateT("Network error!")); return; @@ -40,8 +37,19 @@ void CTeamsProto::OnMessageSent(MHttpResponse *response, AsyncHttpRequest *pRequ CMStringA msgId(pRoot["OriginalArrivalTime"].as_mstring()); if (pMessage) { - pMessage->iTimestamp = _atoi64(msgId); - ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)pMessage->hMessage, (LPARAM)msgId.c_str()); + if (auto *si = Chat_Find(hContact)) { + GCEVENT gce = { si, GC_EVENT_MESSAGE }; + gce.dwFlags = GCEF_ADDTOLOG | GCEF_UTF8; + gce.pszUID.a = m_szOwnSkypeId; + gce.pszText.a = pMessage->szMessage; + gce.time = time(0); + gce.bIsMe = true; + Chat_Event(&gce); + } + else { + pMessage->iTimestamp = _atoi64(msgId); + ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)pMessage->hMessage, (LPARAM)msgId.c_str()); + } mir_cslock lck(m_lckOutMessagesList); m_OutMessages.remove(pMessage.get()); diff --git a/protocols/Teams/src/teams_proto.h b/protocols/Teams/src/teams_proto.h index 194072532d..5f502106b9 100644 --- a/protocols/Teams/src/teams_proto.h +++ b/protocols/Teams/src/teams_proto.h @@ -17,8 +17,15 @@ struct COwnMessage hClientMessageId(_2) {} + COwnMessage(const char *pszText) : + hMessage(0), + hClientMessageId(0), + szMessage(mir_strdup(pszText)) + {} + int hMessage; int64_t hClientMessageId, iTimestamp = -1; + ptrA szMessage; }; struct CSkypeTransfer |