From 70b77d0c25f8138e30d78d3af7966711cff3b375 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 1 Mar 2019 17:54:28 +0300 Subject: fixes #1871 (SkypeWeb: after synchronization, edited message is deleted in Miranda NG, and not replaced with edited message) --- protocols/SkypeWeb/src/skype_db.cpp | 10 ++++++---- protocols/SkypeWeb/src/skype_history_sync.cpp | 2 +- protocols/SkypeWeb/src/skype_messages.cpp | 2 +- protocols/SkypeWeb/src/skype_proto.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) (limited to 'protocols/SkypeWeb/src') diff --git a/protocols/SkypeWeb/src/skype_db.cpp b/protocols/SkypeWeb/src/skype_db.cpp index f26673d8ad..63e7b9aa32 100644 --- a/protocols/SkypeWeb/src/skype_db.cpp +++ b/protocols/SkypeWeb/src/skype_db.cpp @@ -49,7 +49,7 @@ MEVENT CSkypeProto::AddDbEvent(WORD type, MCONTACT hContact, DWORD timestamp, DW return ret; } -MEVENT CSkypeProto::AppendDBEvent(MCONTACT hContact, MEVENT hEvent, const char *szContent, const char *szUid, time_t edit_time) +void CSkypeProto::EditEvent(MCONTACT hContact, MEVENT hEvent, const char *szContent, time_t edit_time) { mir_cslock lck(m_AppendMessageLock); DBEVENTINFO dbei = {}; @@ -66,7 +66,7 @@ MEVENT CSkypeProto::AppendDBEvent(MCONTACT hContact, MEVENT hEvent, const char * const JSONNode &jEdit = *it; if (jEdit["time"].as_int() == edit_time) - return hEvent; + return; } JSONNode jEdit; jEdit @@ -96,8 +96,10 @@ MEVENT CSkypeProto::AppendDBEvent(MCONTACT hContact, MEVENT hEvent, const char * jMsg << jEdits; } - db_event_delete(hContact, hEvent); - return AddDbEvent(SKYPE_DB_EVENT_TYPE_EDITED_MESSAGE, hContact, dbei.timestamp, dbei.flags, jMsg.write().c_str(), szUid); + std::string newMsg = jMsg.write().c_str(); + dbei.cbBlob = newMsg.size() + 1; + dbei.pBlob = (PBYTE)newMsg.c_str(); + db_event_edit(hContact, hEvent, &dbei); } MEVENT CSkypeProto::AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, DWORD cbBlob, PBYTE pBlob) diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp index 7c68efabbf..2d05c40e54 100644 --- a/protocols/SkypeWeb/src/skype_history_sync.cpp +++ b/protocols/SkypeWeb/src/skype_history_sync.cpp @@ -72,7 +72,7 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response) ptrA szMessage(messageType == "RichText" ? RemoveHtml(content.c_str()) : mir_strdup(content.c_str())); MEVENT dbevent = GetMessageFromDb(szMessageId); if (isEdited && dbevent != NULL) - AppendDBEvent(hContact, dbevent, szMessage, szMessageId, timestamp); + EditEvent(hContact, dbevent, szMessage, timestamp); else AddDbEvent(emoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, hContact, timestamp, iFlags, &szMessage[emoteOffset], szMessageId); } diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index 15ab266d30..17021d1030 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -156,7 +156,7 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node) MEVENT hDbEvent = GetMessageFromDb(szMessageId); if (bEdited && hDbEvent != NULL) - AppendDBEvent(hContact, hDbEvent, szClearedContent, szMessageId, timestamp); + EditEvent(hContact, hDbEvent, szClearedContent, timestamp); else OnReceiveMessage(hContact, szClearedContent, szMessageId, timestamp, nEmoteOffset); } diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index cdf53ac492..7a15904c76 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -291,7 +291,7 @@ private: MEVENT GetMessageFromDb(const char *messageId); MEVENT AddDbEvent(WORD type, MCONTACT hContact, DWORD timestamp, DWORD flags, const char *content, const char *uid); - MEVENT AppendDBEvent(MCONTACT hContact, MEVENT hEvent, const char *szContent, const char *szUid, time_t edit_time); + void EditEvent(MCONTACT hContact, MEVENT hEvent, const char *szContent, time_t edit_time); int OnReceiveMessage(MCONTACT hContact, const char *szContent, const char *szMessageId, time_t timestamp, int emoteOffset = 0, bool isRead = false); int OnSendMessage(MCONTACT hContact, int flags, const char *message); -- cgit v1.2.3