summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-09-08 15:27:08 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-09-08 15:27:08 +0300
commitec6025510d1330001b76ea57291386b22377c653 (patch)
tree870e1972eb9e9134c066776eed993f94004d4e4f /protocols
parent664dbdb0cb541f5bcfe334a73a2166a5a25d8920 (diff)
fixes #4630 (Skypeweb: не работает удаление сообщения с сервера)
Diffstat (limited to 'protocols')
-rw-r--r--protocols/SkypeWeb/src/request_queue.cpp5
-rw-r--r--protocols/SkypeWeb/src/requests/endpoint.h2
-rw-r--r--protocols/SkypeWeb/src/requests/messages.h16
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp4
-rw-r--r--protocols/SkypeWeb/src/skype_menus.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp7
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp10
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h1
-rw-r--r--protocols/SkypeWeb/src/stdafx.h1
9 files changed, 38 insertions, 10 deletions
diff --git a/protocols/SkypeWeb/src/request_queue.cpp b/protocols/SkypeWeb/src/request_queue.cpp
index 3e1c51e57b..cc112052bd 100644
--- a/protocols/SkypeWeb/src/request_queue.cpp
+++ b/protocols/SkypeWeb/src/request_queue.cpp
@@ -40,6 +40,11 @@ AsyncHttpRequest::AsyncHttpRequest(int type, SkypeHost host, LPCSTR url, MTHttpR
requestType = type;
}
+void AsyncHttpRequest::AddAuthentication(CSkypeProto *ppro)
+{
+ AddHeader("Authentication", CMStringA("skypetoken=") + ppro->m_szApiToken);
+}
+
void AsyncHttpRequest::AddRegister(CSkypeProto *ppro)
{
AddHeader("RegistrationToken", CMStringA("registrationToken=") + ppro->m_szToken);
diff --git a/protocols/SkypeWeb/src/requests/endpoint.h b/protocols/SkypeWeb/src/requests/endpoint.h
index 4e83bd98d4..4f15d4b534 100644
--- a/protocols/SkypeWeb/src/requests/endpoint.h
+++ b/protocols/SkypeWeb/src/requests/endpoint.h
@@ -25,7 +25,7 @@ struct CreateEndpointRequest : public AsyncHttpRequest
{
m_szParam = "{}";
- AddHeader("Authentication", CMStringA(FORMAT, "skypetoken=%s", ppro->m_szApiToken.get()));
+ AddAuthentication(ppro);
}
};
diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h
index a6d9cf4916..378c8d8549 100644
--- a/protocols/SkypeWeb/src/requests/messages.h
+++ b/protocols/SkypeWeb/src/requests/messages.h
@@ -69,13 +69,23 @@ struct SendTypingRequest : public AsyncHttpRequest
}
};
+struct DeleteMessageRequest : public AsyncHttpRequest
+{
+ DeleteMessageRequest(CSkypeProto *ppro, const char *username, const char *msgId) :
+ AsyncHttpRequest(REQUEST_DELETE, HOST_DEFAULT, "/users/ME/conversations/" + mir_urlEncode(username) + "/messages/" + msgId)
+ {
+ AddAuthentication(ppro);
+
+ AddHeader("Origin", "https://web.skype.com");
+ AddHeader("Referer", "https://web.skype.com/");
+ }
+};
+
struct MarkMessageReadRequest : public AsyncHttpRequest
{
MarkMessageReadRequest(const char *username, int64_t msgTimestamp) :
- AsyncHttpRequest(REQUEST_PUT, HOST_DEFAULT)
+ AsyncHttpRequest(REQUEST_PUT, HOST_DEFAULT, "/users/ME/conversations/" + mir_urlEncode(username) + "/properties?name=consumptionhorizon")
{
- m_szUrl.AppendFormat("/users/ME/conversations/%s/properties?name=consumptionhorizon", mir_urlEncode(username).c_str());
-
JSONNode node(JSON_NODE);
node << CHAR_PARAM("consumptionhorizon", CMStringA(::FORMAT, "%lld;%lld;%lld", msgTimestamp, msgTimestamp, msgTimestamp));
m_szParam = node.write().c_str();
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index 11c731ec23..577c1433e9 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -42,7 +42,7 @@ void CSkypeProto::OnGetServerHistory(MHttpResponse *response, AsyncHttpRequest *
auto &conv = root["messages"];
for (auto it = conv.rbegin(); it != conv.rend(); ++it) {
auto &message = *it;
- CMStringA szMessageId = message["clientmessageid"] ? message["clientmessageid"].as_string().c_str() : message["skypeeditedid"].as_string().c_str();
+ CMStringA szMessageId = message["id"].as_mstring();
int iUserType;
CMStringA szChatId = UrlToSkypeId(message["conversationLink"].as_mstring(), &iUserType);
@@ -58,7 +58,7 @@ void CSkypeProto::OnGetServerHistory(MHttpResponse *response, AsyncHttpRequest *
if (iUserType == 19)
dbei.szUserId = szFrom;
- int64_t id = _atoi64(message["id"].as_string().c_str());
+ int64_t id = _atoi64(szMessageId);
if (id > lastMsgTime) {
bSetLastTime = true;
lastMsgTime = id;
diff --git a/protocols/SkypeWeb/src/skype_menus.cpp b/protocols/SkypeWeb/src/skype_menus.cpp
index 5e8b35c632..021c2991f1 100644
--- a/protocols/SkypeWeb/src/skype_menus.cpp
+++ b/protocols/SkypeWeb/src/skype_menus.cpp
@@ -55,8 +55,6 @@ void CSkypeProto::InitMenus()
{
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CSkypeProto::PrebuildContactMenu);
- //hChooserMenu = Menu_AddObject("SkypeAccountChooser", LPGEN("Skype menu chooser"), 0, "Skype/MenuChoose");
-
CMenuItem mi(&g_plugin);
mi.flags = CMIF_UNICODE;
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index db01c0308e..76b2e772d7 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -93,12 +93,15 @@ bool CSkypeProto::ParseMessage(const JSONNode &node, DB::EventInfo &dbei)
auto &pContent = node["content"];
if (!pContent) {
+LBL_Deleted:
if (dbei)
db_event_delete(dbei.getEvent());
return false;
}
CMStringW wszContent = pContent.as_mstring();
+ if (wszContent.IsEmpty())
+ goto LBL_Deleted;
std::string strMessageType = node["messagetype"].as_string();
if (strMessageType == "RichText/Media_GenericFile" || strMessageType == "RichText/Media_Video" || strMessageType == "RichText/UriObject" ) {
@@ -153,14 +156,14 @@ void CSkypeProto::ProcessNewMessage(const JSONNode &node)
int iUserType;
UrlToSkypeId(node["conversationLink"].as_string().c_str(), &iUserType);
- CMStringA szMessageId = node["clientmessageid"] ? node["clientmessageid"].as_mstring() : node["skypeeditedid"].as_mstring();
+ CMStringA szMessageId = node["id"].as_mstring();
CMStringA szConversationName(UrlToSkypeId(node["conversationLink"].as_string().c_str()));
CMStringA szFromSkypename(UrlToSkypeId(node["from"].as_mstring()));
MCONTACT hContact = AddContact(szConversationName, nullptr, true);
if (m_bHistorySynced) {
- int64_t lastMsgId = _atoi64(node["id"].as_string().c_str());
+ int64_t lastMsgId = _atoi64(szMessageId);
if (lastMsgId > getLastTime(hContact))
setLastTime(hContact, lastMsgId);
}
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp
index 148be02f4e..70ed909cc4 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -69,6 +69,16 @@ CSkypeProto::~CSkypeProto()
UninitPopups();
}
+void CSkypeProto::OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent, int flags)
+{
+ if (!hContact || !(flags & CDF_DEL_HISTORY))
+ return;
+
+ DB::EventInfo dbei(hDbEvent, false);
+ if (dbei.szId)
+ PushRequest(new DeleteMessageRequest(this, getId(hContact), dbei.szId));
+}
+
void CSkypeProto::OnModulesLoaded()
{
setAllContactStatuses(ID_STATUS_OFFLINE, false);
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 6f13fa6da6..ab24cf192b 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -75,6 +75,7 @@ public:
void OnBuildProtoMenu(void) override;
bool OnContactDeleted(MCONTACT, uint32_t flags) override;
MWindow OnCreateAccMgrUI(MWindow) override;
+ void OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent, int flags) override;
void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
void OnReceiveOfflineFile(DB::FILE_BLOB &blob) override;
diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h
index 579cf506f4..73d40365ba 100644
--- a/protocols/SkypeWeb/src/stdafx.h
+++ b/protocols/SkypeWeb/src/stdafx.h
@@ -109,6 +109,7 @@ struct AsyncHttpRequest : public MTHttpRequest<CSkypeProto>
AsyncHttpRequest(int type, SkypeHost host, LPCSTR url = nullptr, MTHttpRequestHandler pFunc = nullptr);
void AddRegister(CSkypeProto *ppro);
+ void AddAuthentication(CSkypeProto *ppro);
};
#include "requests/avatars.h"