From e808179197e8875f3faa85ad8f0d1e75d756716f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 1 Oct 2018 15:36:26 +0300 Subject: centralized system of processing message ids. also fixes #1375 --- src/mir_app/src/proto_utils.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/mir_app') 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); } -- cgit v1.2.3