summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-08-08 11:42:18 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-08-08 11:42:18 +0300
commit92fba480e36acb126781ad27510aaaecf084b9d1 (patch)
tree13de57779631facbb3576cf1eac5064c93fac160 /protocols
parent0b16ad5c516ef3f32e6d981e0c26369991cefec9 (diff)
SkypeWeb: duplicate query removed
Diffstat (limited to 'protocols')
-rw-r--r--protocols/SkypeWeb/src/requests/chatrooms.h10
-rw-r--r--protocols/SkypeWeb/src/requests/history.h8
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp19
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp11
-rw-r--r--protocols/SkypeWeb/src/skype_login.cpp5
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h1
6 files changed, 13 insertions, 41 deletions
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h
index 912d6fc4bf..a023a6bbe5 100644
--- a/protocols/SkypeWeb/src/requests/chatrooms.h
+++ b/protocols/SkypeWeb/src/requests/chatrooms.h
@@ -18,16 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _SKYPE_REQUEST_CHATS_H_
#define _SKYPE_REQUEST_CHATS_H_
-struct LoadChatsRequest : public AsyncHttpRequest
-{
- LoadChatsRequest() :
- AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, "/users/ME/conversations", &CSkypeProto::OnLoadChats)
- {
- this << INT_PARAM("startTime", 0) << INT_PARAM("pageSize", 100)
- << CHAR_PARAM("view", "msnp24Equivalent") << CHAR_PARAM("targetType", "Thread");
- }
-};
-
struct SendChatMessageRequest : public AsyncHttpRequest
{
SendChatMessageRequest(const char *to, time_t timestamp, const char *message) :
diff --git a/protocols/SkypeWeb/src/requests/history.h b/protocols/SkypeWeb/src/requests/history.h
index 4e63278f8c..4f25a2ec8c 100644
--- a/protocols/SkypeWeb/src/requests/history.h
+++ b/protocols/SkypeWeb/src/requests/history.h
@@ -18,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _SKYPE_REQUEST_HISTORY_H_
#define _SKYPE_REQUEST_HISTORY_H_
-struct SyncHistoryFirstRequest : public AsyncHttpRequest
+struct SyncConversations : public AsyncHttpRequest
{
- SyncHistoryFirstRequest(int pageSize) :
+ SyncConversations() :
AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, "/users/ME/conversations", &CSkypeProto::OnSyncConversations)
{
- this << INT_PARAM("startTime", 0) << INT_PARAM("pageSize", pageSize)
- << CHAR_PARAM("view", "msnp24Equivalent") << CHAR_PARAM("targetType", "Passport|Skype|Lync");
+ this << INT_PARAM("startTime", 0) << INT_PARAM("pageSize", 100)
+ << CHAR_PARAM("view", "msnp24Equivalent") << CHAR_PARAM("targetType", "Passport|Skype|Lync|Thread");
}
};
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index 118a7ec3e8..eff2eabe7d 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -54,25 +54,6 @@ SESSION_INFO* CSkypeProto::StartChatRoom(const wchar_t *tid, const wchar_t *tnam
return si;
}
-void CSkypeProto::OnLoadChats(MHttpResponse *response, AsyncHttpRequest*)
-{
- JsonReply reply(response);
- if (reply.error())
- return;
-
- auto &root = reply.data();
- // const JSONNode &metadata = root["_metadata"];
- const JSONNode &conversations = root["conversations"].as_array();
-
- // int totalCount = metadata["totalCount"].as_int();
-
- for (auto &it : conversations) {
- auto &props = it["threadProperties"];
- if (it["lastMessage"] && props["members"] && !props["lastleaveat"])
- StartChatRoom(it["id"].as_mstring(), props["topic"].as_mstring());
- }
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// Group chat invitation dialog
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index a1e86c777b..e1f427c6ee 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -104,8 +104,8 @@ void CSkypeProto::OnSyncConversations(MHttpResponse *response, AsyncHttpRequest*
// int totalCount = metadata["totalCount"].as_int();
std::string syncState = metadata["syncState"].as_string();
- for (auto &conversation : conversations) {
- const JSONNode &lastMessage = conversation["lastMessage"];
+ for (auto &it: conversations) {
+ const JSONNode &lastMessage = it["lastMessage"];
if (!lastMessage)
continue;
@@ -118,10 +118,15 @@ void CSkypeProto::OnSyncConversations(MHttpResponse *response, AsyncHttpRequest*
MCONTACT hContact = FindContact(szSkypename);
if (hContact != NULL) {
auto lastMsgTime = getLastTime(hContact);
- if (lastMsgTime && lastMsgTime < id)
+ if (lastMsgTime && lastMsgTime < id && bAutoHistorySync)
PushRequest(new GetHistoryRequest(hContact, szSkypename, 100, lastMsgTime, true));
}
}
+ else if (iUserType == 19) {
+ auto &props = it["threadProperties"];
+ if (props["members"] && !props["lastleaveat"])
+ StartChatRoom(it["id"].as_mstring(), props["topic"].as_mstring());
+ }
}
m_bHistorySynced = true;
diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp
index 09206e19e6..6c802bd420 100644
--- a/protocols/SkypeWeb/src/skype_login.cpp
+++ b/protocols/SkypeWeb/src/skype_login.cpp
@@ -269,12 +269,9 @@ void CSkypeProto::OnCapabilitiesSended(MHttpResponse *response, AsyncHttpRequest
m_hPollingEvent.Set();
- PushRequest(new LoadChatsRequest());
PushRequest(new GetContactListRequest());
PushRequest(new GetAvatarRequest(ptrA(getStringA("AvatarUrl")), 0));
-
- if (bAutoHistorySync)
- PushRequest(new SyncHistoryFirstRequest(100));
+ PushRequest(new SyncConversations());
JSONNode root = JSONNode::parse(response->body);
if (root)
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index c3fd62b343..79c23ebc33 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -161,7 +161,6 @@ public:
void OnGetServerHistory(MHttpResponse *response, AsyncHttpRequest *pRequest);
void OnSyncConversations(MHttpResponse *response, AsyncHttpRequest *pRequest);
- void OnLoadChats(MHttpResponse *response, AsyncHttpRequest *pRequest);
void OnGetChatInfo(MHttpResponse *response, AsyncHttpRequest *pRequest);
void OnReceiveAwayMsg(MHttpResponse *response, AsyncHttpRequest *pRequest);