summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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);
}