diff options
author | George Hazan <ghazan@miranda.im> | 2020-12-23 21:03:01 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-12-23 21:03:01 +0300 |
commit | ed4141e5d48402b8b617e6ae360ae41464723b0c (patch) | |
tree | 2a2974512bef913df3ddbf619f0f881967997af6 /protocols | |
parent | 16c0b34f73ad2c54defd9e2791bd8c15e27e35e0 (diff) |
SkypeWeb: history reader to use local time not to create time machine. Only fetching whole history shall use server side timestamps
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/SkypeWeb/src/requests/history.h | 11 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_chatrooms.cpp | 2 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_history_sync.cpp | 24 |
3 files changed, 21 insertions, 16 deletions
diff --git a/protocols/SkypeWeb/src/requests/history.h b/protocols/SkypeWeb/src/requests/history.h index 6be005ae57..7c5baf6870 100644 --- a/protocols/SkypeWeb/src/requests/history.h +++ b/protocols/SkypeWeb/src/requests/history.h @@ -35,21 +35,22 @@ struct SyncHistoryFirstRequest : public AsyncHttpRequest struct GetHistoryRequest : public AsyncHttpRequest
{
- GetHistoryRequest(const char *username, int pageSize, LONGLONG timestamp) :
+ GetHistoryRequest(const char *username, int pageSize, LONGLONG timestamp, bool bOperative) :
AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, 0, &CSkypeProto::OnGetServerHistory)
{
m_szUrl.AppendFormat("/users/ME/conversations/%s/messages", mir_urlEncode(username).c_str());
+ if (bOperative)
+ pUserInfo = this;
+
this << INT_PARAM("startTime", timestamp) << INT_PARAM("pageSize", pageSize)
<< CHAR_PARAM("view", "msnp24Equivalent") << CHAR_PARAM("targetType", "Passport|Skype|Lync|Thread");
}
-};
-struct GetHistoryOnUrlRequest : public AsyncHttpRequest
-{
- GetHistoryOnUrlRequest(const char *url) :
+ GetHistoryRequest(const char *url, void *pInfo) :
AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, url, &CSkypeProto::OnGetServerHistory)
{
+ pUserInfo = pInfo;
}
};
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 080edd1abb..8cc0b39393 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -406,7 +406,7 @@ void CSkypeProto::OnGetChatInfo(NETLIBHTTPREQUEST *response, AsyncHttpRequest*) AddChatContact(si, username, role, true);
}
- PushRequest(new GetHistoryRequest(_T2A(si->ptszID), true, 0));
+ PushRequest(new GetHistoryRequest(T2Utf(si->ptszID), 100, 0, true));
}
wchar_t* CSkypeProto::GetChatContactNick(MCONTACT hContact, const wchar_t *id, const wchar_t *name)
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp index 60ecb06cf4..57b46c92cc 100644 --- a/protocols/SkypeWeb/src/skype_history_sync.cpp +++ b/protocols/SkypeWeb/src/skype_history_sync.cpp @@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. /* HISTORY SYNC */
-void CSkypeProto::OnGetServerHistory(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
+void CSkypeProto::OnGetServerHistory(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest)
{
JsonReply reply(response);
if (reply.error())
@@ -33,9 +33,11 @@ void CSkypeProto::OnGetServerHistory(NETLIBHTTPREQUEST *response, AsyncHttpReque std::string syncState = metadata["syncState"].as_string();
bool markAllAsUnread = getBool("MarkMesUnread", true);
+ bool bUseLocalTime = pRequest->pUserInfo != 0;
+ time_t iLocalTime = time(0);
if (totalCount >= 99 || conversations.size() >= 99)
- PushRequest(new GetHistoryOnUrlRequest(syncState.c_str()));
+ PushRequest(new GetHistoryRequest(syncState.c_str(), pRequest->pUserInfo));
for (int i = (int)conversations.size(); i >= 0; i--) {
const JSONNode &message = conversations.at(i);
@@ -57,16 +59,18 @@ void CSkypeProto::OnGetServerHistory(NETLIBHTTPREQUEST *response, AsyncHttpReque if (timestamp > getDword(hContact, "LastMsgTime", 0))
setDword(hContact, "LastMsgTime", timestamp);
+ if (bUseLocalTime)
+ timestamp = iLocalTime;
- DWORD iFlags = DBEF_UTF;
+ if (userType == 8 || userType == 2) {
+ DWORD iFlags = DBEF_UTF;
- if (!markAllAsUnread)
- iFlags |= DBEF_READ;
+ if (!markAllAsUnread)
+ iFlags |= DBEF_READ;
- if (IsMe(wszFrom))
- iFlags |= DBEF_SENT;
+ if (IsMe(wszFrom))
+ iFlags |= DBEF_SENT;
- if (userType == 8 || userType == 2) {
if (messageType == "Text" || messageType == "RichText") {
CMStringW szMessage(messageType == "RichText" ? RemoveHtml(wszContent) : wszContent);
MEVENT dbevent = GetMessageFromDb(szMessageId);
@@ -114,7 +118,7 @@ void CSkypeProto::ReadHistoryRest(const char *szUrl) INT_PTR CSkypeProto::GetContactHistory(WPARAM hContact, LPARAM)
{
- PushRequest(new GetHistoryRequest(getId(hContact), 100, 0));
+ PushRequest(new GetHistoryRequest(getId(hContact), 100, 0, false));
return 0;
}
@@ -148,7 +152,7 @@ void CSkypeProto::OnSyncHistory(NETLIBHTTPREQUEST *response, AsyncHttpRequest*) MCONTACT hContact = FindContact(szSkypename);
if (hContact != NULL)
if (getDword(hContact, "LastMsgTime", 0) < composeTime)
- PushRequest(new GetHistoryRequest(szSkypename, 100, 0));
+ PushRequest(new GetHistoryRequest(szSkypename, 100, 0, true));
}
}
|