summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Teams/src/teams_history.cpp24
-rw-r--r--protocols/Teams/src/teams_messages.cpp6
2 files changed, 16 insertions, 14 deletions
diff --git a/protocols/Teams/src/teams_history.cpp b/protocols/Teams/src/teams_history.cpp
index 6930e90382..4e16c4261d 100644
--- a/protocols/Teams/src/teams_history.cpp
+++ b/protocols/Teams/src/teams_history.cpp
@@ -19,15 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* HISTORY SYNC */
-void CTeamsProto::RefreshConversations()
-{
- auto *pReq = new AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, "/users/ME/conversations", &CTeamsProto::OnSyncConversations);
- pReq << INT64_PARAM("startTime", getLastTime(0)) << INT_PARAM("pageSize", 100)
- << CHAR_PARAM("view", "msnp24Equivalent") << CHAR_PARAM("targetType", "Passport|Skype|Lync|Thread|PSTN|Agent");
-
- PushRequest(pReq);
-}
-
void CTeamsProto::FetchMissingHistory(const JSONNode &node, MCONTACT hContact)
{
const JSONNode &lastMessage = node["lastMessage"];
@@ -46,7 +37,6 @@ void CTeamsProto::OnSyncConversations(MHttpResponse *response, AsyncHttpRequest
return;
auto &root = reply.data();
- const JSONNode &metadata = root["_metadata"];
const JSONNode &conversations = root["conversations"].as_array();
for (auto &it : conversations) {
@@ -90,11 +80,19 @@ void CTeamsProto::OnSyncConversations(MHttpResponse *response, AsyncHttpRequest
}
}
- std::string syncState = metadata["syncState"].as_string();
m_bHistorySynced = true;
}
+void CTeamsProto::RefreshConversations()
+{
+ auto *pReq = new AsyncHttpRequest(REQUEST_GET, HOST_CHATS, "/users/ME/conversations", &CTeamsProto::OnSyncConversations);
+ pReq << INT64_PARAM("startTime", 0) << INT_PARAM("pageSize", 100)
+ << CHAR_PARAM("view", "msnp24Equivalent") << CHAR_PARAM("targetType", "Passport|Skype|Lync|Thread|PSTN|Agent");
+
+ PushRequest(pReq);
+}
+
//////////////////////////////////////////////////////////////////////////////////////////
void CTeamsProto::GetServerHistory(MCONTACT hContact, int pageSize, int64_t timestamp, bool bOperative)
@@ -103,7 +101,7 @@ void CTeamsProto::GetServerHistory(MCONTACT hContact, int pageSize, int64_t time
if (szChatId.IsEmpty())
szChatId = getId(hContact);
- auto *pReq = new AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, "/users/ME/conversations/" + mir_urlEncode(szChatId) + "/messages", &CTeamsProto::OnGetServerHistory);
+ auto *pReq = new AsyncHttpRequest(REQUEST_GET, HOST_CHATS, "/users/ME/conversations/" + mir_urlEncode(szChatId) + "/messages", &CTeamsProto::OnGetServerHistory);
pReq->hContact = hContact;
if (bOperative)
pReq->pUserInfo = this;
@@ -191,7 +189,7 @@ INT_PTR CTeamsProto::SvcLoadHistory(WPARAM hContact, LPARAM)
INT_PTR CTeamsProto::SvcEmptyHistory(WPARAM hContact, LPARAM flags)
{
if (flags & CDF_DEL_HISTORY)
- PushRequest(new AsyncHttpRequest(REQUEST_DELETE, HOST_DEFAULT, "/users/ME/conversations/" + mir_urlEncode(getId(hContact)) + "/messages"));
+ PushRequest(new AsyncHttpRequest(REQUEST_DELETE, HOST_CHATS, "/users/ME/conversations/" + mir_urlEncode(getId(hContact)) + "/messages"));
return 0;
}
diff --git a/protocols/Teams/src/teams_messages.cpp b/protocols/Teams/src/teams_messages.cpp
index cba7809839..beb077eb64 100644
--- a/protocols/Teams/src/teams_messages.cpp
+++ b/protocols/Teams/src/teams_messages.cpp
@@ -81,7 +81,11 @@ int CTeamsProto::SendServerMsg(MCONTACT hContact, const char *szMessage, int64_t
bool bRich = AddBbcodes(str);
m_iMessageId++;
- CMStringA szUrl = "/users/ME/conversations/" + mir_urlEncode(getId(hContact)) + "/messages";
+ CMStringA szChatId(getMStringA(hContact, "ChatId"));
+ if (szChatId.IsEmpty())
+ szChatId = getId(hContact);
+
+ CMStringA szUrl = "/users/ME/conversations/" + mir_urlEncode(szChatId) + "/messages";
if (existingMsgId)
szUrl.AppendFormat("/%lld", existingMsgId);