summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-10-01 15:36:26 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-10-01 15:36:26 +0300
commite808179197e8875f3faa85ad8f0d1e75d756716f (patch)
tree6ca118531ebf3d2d85a0123171298e74b2decbd6 /src
parent966214ad3db583c8e8cbfbae4281705f73df4429 (diff)
centralized system of processing message ids. also fixes #1375
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/proto_utils.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp
index a09fb63ec6..a82f92eb78 100644
--- a/src/mir_app/src/proto_utils.cpp
+++ b/src/mir_app/src/proto_utils.cpp
@@ -514,6 +514,20 @@ MEVENT PROTO_INTERFACE::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre)
if (pre->flags & PREF_SENT)
dbei.flags |= DBEF_SENT;
+ // if it's possible to find an existing event by its id, do that
+ if ((GetCaps(PFLAGNUM_4) & PF4_SERVERMSGID) && pre->szMsgId != nullptr) {
+ MEVENT hDbEvent = db_event_getById(m_szModuleName, pre->szMsgId);
+ if (hDbEvent == 0) {
+ hDbEvent = db_event_add(hContact, &dbei);
+ if (hDbEvent)
+ db_event_setId(m_szModuleName, hDbEvent, pre->szMsgId);
+ }
+ else db_event_edit(hContact, hDbEvent, &dbei);
+
+ return hDbEvent;
+ }
+
+ // event is new? add it
return (INT_PTR)db_event_add(hContact, &dbei);
}