summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_messages.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Steam/src/steam_messages.cpp')
-rw-r--r--protocols/Steam/src/steam_messages.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp
index 1a51cccb90..f55a31366a 100644
--- a/protocols/Steam/src/steam_messages.cpp
+++ b/protocols/Steam/src/steam_messages.cpp
@@ -40,6 +40,7 @@ void CSteamProto::OnMessageSent(const HttpResponse *response, void *arg)
ptrT error(mir_tstrdup(TranslateT("Unknown error")));
ptrT steamId(getTStringA(param->hContact, "SteamID"));
+ time_t timestamp = NULL;
if (ResponseHttpOk(response))
{
@@ -47,6 +48,10 @@ void CSteamProto::OnMessageSent(const HttpResponse *response, void *arg)
JSONNode *node = json_get(root, "error");
if (node)
error = json_as_string(node);
+
+ node = json_get(root, "utc_timestamp");
+ if (node)
+ timestamp = atol(ptrA(mir_t2a(ptrT(json_as_string(node)))));
}
if (mir_tstrcmpi(error, _T("OK")) != 0)
@@ -56,5 +61,28 @@ void CSteamProto::OnMessageSent(const HttpResponse *response, void *arg)
ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hMessage, (LPARAM)errorA);
}
else
+ {
+ // remember server time of this message
+ auto it = m_mpOutMessages.find(param->hMessage);
+ if (it == m_mpOutMessages.end() && timestamp != NULL)
+ m_mpOutMessages[param->hMessage] = timestamp;
+
ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hMessage, 0);
-} \ No newline at end of file
+ }
+}
+
+int CSteamProto::OnPreCreateMessage(WPARAM, LPARAM lParam)
+{
+ MessageWindowEvent *evt = (MessageWindowEvent*)lParam;
+ if (mir_strcmp(GetContactProto(evt->hContact), m_szModuleName))
+ return 0;
+
+ auto it = m_mpOutMessages.find((HANDLE)evt->seq);
+ if (it != m_mpOutMessages.end())
+ {
+ evt->dbei->timestamp = it->second;
+ m_mpOutMessages.erase(it);
+ }
+
+ return 0;
+}