diff options
author | George Hazan <george.hazan@gmail.com> | 2024-12-27 20:06:34 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-12-27 20:06:34 +0300 |
commit | 8771dda88d2ea3ac304414c8c4d4232ab7beedc1 (patch) | |
tree | 8992b961eee2a2964a5fa364aa031551b7aa788b /protocols/Steam/src | |
parent | 1b9a0663b03e8225afe0f5f40a4949dbd4adc798 (diff) |
no need to fetch the same messages twice
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r-- | protocols/Steam/src/steam_history.cpp | 48 | ||||
-rw-r--r-- | protocols/Steam/src/steam_server.cpp | 1 |
2 files changed, 39 insertions, 10 deletions
diff --git a/protocols/Steam/src/steam_history.cpp b/protocols/Steam/src/steam_history.cpp index 616f54c9df..65c77f490c 100644 --- a/protocols/Steam/src/steam_history.cpp +++ b/protocols/Steam/src/steam_history.cpp @@ -22,25 +22,38 @@ void CSteamProto::OnGotRecentMessages(const CFriendMessagesGetRecentMessagesResp if (!hContact) continue; + MEVENT hEvent; char szMsgId[100]; - itoa(pMsg->timestamp, szMsgId, 10); + if (pMsg->has_timestamp) { + itoa(pMsg->timestamp, szMsgId, 10); + hEvent = db_event_getById(m_szModuleName, szMsgId); + } + else hEvent = 0; - DB::EventInfo dbei(pMsg->has_timestamp ? db_event_getById(m_szModuleName, szMsgId) : 0); + DB::EventInfo dbei(hEvent); dbei.flags = DBEF_UTF; if (steamId == m_iSteamId) dbei.flags |= DBEF_SENT; dbei.cbBlob = (int)mir_strlen(pMsg->message); dbei.pBlob = mir_strdup(pMsg->message); - dbei.timestamp = pMsg->has_timestamp ? pMsg->timestamp : time(0); - dbei.szId = szMsgId; + if (pMsg->has_timestamp) { + if (getDword(hContact, DBKEY_LASTMSG) < pMsg->timestamp) + setDword(hContact, DBKEY_LASTMSG, pMsg->timestamp); + + dbei.szId = szMsgId; + dbei.timestamp = pMsg->timestamp; + } + else dbei.timestamp = time(0); if (dbei.getEvent()) - db_event_edit(dbei.getEvent(), &dbei, true); + db_event_edit(hEvent, &dbei, true); else ProtoChainRecvMsg(hContact, dbei); } } +///////////////////////////////////////////////////////////////////////////////////////// + void CSteamProto::OnGotConversations(const CFriendsMessagesGetActiveMessageSessionsResponse &reply, const CMsgProtoBufHeader &hdr) { if (hdr.failed()) @@ -69,13 +82,23 @@ void CSteamProto::OnGotHistoryMessages(const CMsgClientChatGetFriendMessageHisto if (!hContact) return; + uint32_t iLastMessage = getDword(hContact, DBKEY_LASTMSG); + for (int i = 0; i < reply.n_messages; i++) { auto *pMsg = reply.messages[i]; + MEVENT hEvent; char szMsgId[100]; - itoa(pMsg->timestamp, szMsgId, 10); - DB::EventInfo dbei(pMsg->has_timestamp ? db_event_getById(m_szModuleName, szMsgId) : 0); + if (pMsg->has_timestamp) { + if (iLastMessage < pMsg->timestamp) + iLastMessage = pMsg->timestamp; + itoa(pMsg->timestamp, szMsgId, 10); + hEvent = db_event_getById(m_szModuleName, szMsgId); + } + else hEvent = 0; + + DB::EventInfo dbei(hEvent); dbei.flags = DBEF_UTF; if (pMsg->has_unread && !pMsg->unread) dbei.flags |= DBEF_READ; @@ -83,12 +106,17 @@ void CSteamProto::OnGotHistoryMessages(const CMsgClientChatGetFriendMessageHisto dbei.flags |= DBEF_SENT; dbei.cbBlob = (int)mir_strlen(pMsg->message); dbei.pBlob = mir_strdup(pMsg->message); - dbei.timestamp = pMsg->has_timestamp ? pMsg->timestamp : time(0); - dbei.szId = szMsgId; + if (pMsg->has_timestamp) { + dbei.timestamp = pMsg->timestamp; + dbei.szId = szMsgId; + } + else dbei.timestamp = time(0); if (dbei.getEvent()) - db_event_edit(dbei.getEvent(), &dbei, true); + db_event_edit(hEvent, &dbei, true); else ProtoChainRecvMsg(hContact, dbei); } + + setDword(hContact, DBKEY_LASTMSG, iLastMessage); } diff --git a/protocols/Steam/src/steam_server.cpp b/protocols/Steam/src/steam_server.cpp index c0f7e8b7fe..40789e9a22 100644 --- a/protocols/Steam/src/steam_server.cpp +++ b/protocols/Steam/src/steam_server.cpp @@ -41,6 +41,7 @@ void CSteamProto::SendAppInfoRequest(uint32_t appId) CMsgClientPICSProductInfoRequest request; request.n_apps = 1; request.apps = &pInfo; + request.has_meta_data_only = request.meta_data_only = true; WSSend(EMsg::ClientPICSProductInfoRequest, request); } |