summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-02-09 18:21:23 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-02-09 18:22:12 +0300
commit5ef0585dbd3bfbc09093bc8f24f41e4ae2349c59 (patch)
treeb76db3dc8173189591d65cc9a1a4e181331ca8f8 /protocols
parent6ef65121fed3c38c467238a08bf96bf98a23d7d8 (diff)
SRMM: better support for group chats in database
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Facebook/src/proto.cpp2
-rw-r--r--protocols/Facebook/src/server.cpp41
-rw-r--r--protocols/ICQ-WIM/src/proto.cpp2
-rw-r--r--protocols/ICQ-WIM/src/server.cpp35
-rw-r--r--protocols/IRCG/src/commandmonitor.cpp2
-rw-r--r--protocols/IRCG/src/irclib.cpp2
-rw-r--r--protocols/Sametime/src/messaging.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp2
-rw-r--r--protocols/Tox/src/tox_contacts.cpp2
9 files changed, 25 insertions, 65 deletions
diff --git a/protocols/Facebook/src/proto.cpp b/protocols/Facebook/src/proto.cpp
index b773e6b7b0..f594a7ad91 100644
--- a/protocols/Facebook/src/proto.cpp
+++ b/protocols/Facebook/src/proto.cpp
@@ -112,7 +112,7 @@ FacebookProto::FacebookProto(const char *proto_name, const wchar_t *username) :
// Group chats
GCREGISTER gcr = {};
- gcr.dwFlags = GC_TYPNOTIF;
+ gcr.dwFlags = GC_TYPNOTIF | GC_DATABASE;
gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
Chat_Register(&gcr);
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
index 8a3aa1819d..cae092fcbd 100644
--- a/protocols/Facebook/src/server.cpp
+++ b/protocols/Facebook/src/server.cpp
@@ -863,36 +863,17 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root)
}
// if that's a group chat, send it to the room
- CMStringW wszActorFbId(metadata["actorFbId"].as_mstring());
- __int64 actorFbId = _wtoi64(wszActorFbId);
-
- if (pUser->bIsChat) {
- szBody.Replace("%", "%%");
- ptrW wszText(mir_utf8decodeW(szBody));
-
- // TODO: GC_EVENT_JOIN for chat participants which are missing (for example added later during group chat)
-
- GCEVENT gce = { pUser->si, GC_EVENT_MESSAGE };
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.pszUID.w = wszActorFbId;
- gce.pszText.w = wszText;
- gce.time = time(0);
- gce.bIsMe = actorFbId == m_uid;
- Chat_Event(&gce);
-
- debugLogA("New channel %lld message from %S: %s", pUser->id, gce.pszUID.w, gce.pszText.w);
- }
- else { // otherwise store a private message
- PROTORECVEVENT pre = {};
- pre.timestamp = uint32_t(_wtoi64(metadata["timestamp"].as_mstring()) / 1000);
- pre.szMessage = (char *)szBody.c_str();
- pre.szMsgId = (char *)szId.c_str();
-
- if (m_uid == actorFbId)
- pre.flags |= PREF_SENT;
-
- ProtoChainRecvMsg(pUser->hContact, &pre);
- }
+ auto szActorFbId(metadata["actorFbId"].as_string());
+
+ PROTORECVEVENT pre = {};
+ pre.timestamp = uint32_t(_wtoi64(metadata["timestamp"].as_mstring()) / 1000);
+ pre.szMessage = (char *)szBody.c_str();
+ pre.szMsgId = (char *)szId.c_str();
+ if (m_uid == _atoi64(szActorFbId.c_str()))
+ pre.flags |= PREF_SENT;
+ if (pUser->bIsChat)
+ pre.szUserId = szActorFbId.c_str();
+ ProtoChainRecvMsg(pUser->hContact, &pre);
}
// changing thread name
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp
index f1ff831f63..ec3dd49ce6 100644
--- a/protocols/ICQ-WIM/src/proto.cpp
+++ b/protocols/ICQ-WIM/src/proto.cpp
@@ -83,7 +83,7 @@ CIcqProto::CIcqProto(const char *aProtoName, const wchar_t *aUserName) :
// group chats
GCREGISTER gcr = {};
- gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR;
+ gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_DATABASE;
gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
Chat_Register(&gcr);
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index d8f203dfc9..562cdbaa8e 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -486,32 +486,6 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo
}
}
- if (isChatRoom(hContact)) {
- CMStringA reqId(it["reqId"].as_mstring());
- CheckOwnMessage(reqId, szMsgId, true);
-
- CMStringW wszSender(it["chat"]["sender"].as_mstring());
- CMStringW wszChatId(GetUserId(hContact));
-
- if (bIsFileTransfer) {
- wszText = pFileInfo->szUrl;
- if (!pFileInfo->wszDescr)
- wszText.AppendFormat(L"\r\n%s", pFileInfo->wszDescr.c_str());
- delete pFileInfo;
- }
-
- if (auto *si = Chat_Find(wszChatId, m_szModuleName)) {
- GCEVENT gce = { si, GC_EVENT_MESSAGE};
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.pszUID.w = wszSender;
- gce.pszText.w = wszText;
- gce.time = iMsgTime;
- gce.bIsMe = wszSender == m_szOwnId;
- Chat_Event(&gce);
- }
- return;
- }
-
// skip own messages, just set the server msgid
CMStringA reqId(it["reqId"].as_mstring());
if (CheckOwnMessage(reqId, szMsgId, true)) {
@@ -555,13 +529,18 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo
debugLogA("Adding message %d:%lld (CR=%d)", hContact, msgId, bCreateRead);
ptrA szUtf(mir_utf8encodeW(wszText));
+ CMStringA szSender(it["chat"]["sender"].as_mstring());
PROTORECVEVENT pre = {};
- if (bIsOutgoing) pre.flags |= PREF_SENT;
- if (bCreateRead) pre.flags |= PREF_CREATEREAD;
pre.szMsgId = szMsgId;
pre.timestamp = iMsgTime;
pre.szMessage = szUtf;
+ if (bIsOutgoing)
+ pre.flags |= PREF_SENT;
+ if (bCreateRead)
+ pre.flags |= PREF_CREATEREAD;
+ if (isChatRoom(hContact))
+ pre.szUserId = szSender;
ProtoChainRecvMsg(hContact, &pre);
}
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp
index 5e0705dfe8..9eb66f8aaa 100644
--- a/protocols/IRCG/src/commandmonitor.cpp
+++ b/protocols/IRCG/src/commandmonitor.cpp
@@ -688,7 +688,7 @@ bool CIrcProto::OnIrc_PRIVMSG(const CIrcMessage *pmsg)
MCONTACT hContact = CList_AddContact(&user, false, true);
- PROTORECVEVENT pre = { 0 };
+ PROTORECVEVENT pre = {};
pre.timestamp = (uint32_t)time(0);
pre.szMessage = mir_utf8encodeW(mess);
setWString(hContact, "User", pmsg->prefix.sUser);
diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp
index aedbe97af5..cad89607c5 100644
--- a/protocols/IRCG/src/irclib.cpp
+++ b/protocols/IRCG/src/irclib.cpp
@@ -1274,7 +1274,7 @@ void CDccSession::DoChatReceive()
if (*pStart) {
// send it off to some messaging module
- PROTORECVEVENT pre = { 0 };
+ PROTORECVEVENT pre = {};
pre.timestamp = (uint32_t)time(0);
pre.szMessage = pStart;
ProtoChainRecvMsg(di->hContact, &pre);
diff --git a/protocols/Sametime/src/messaging.cpp b/protocols/Sametime/src/messaging.cpp
index c8c3cb64cb..4def7ca30d 100644
--- a/protocols/Sametime/src/messaging.cpp
+++ b/protocols/Sametime/src/messaging.cpp
@@ -81,7 +81,7 @@ void mwIm_conversation_recv(mwConversation* conv, mwImSendType type, gconstpoint
if (type != mwImSend_PLAIN)
return;
- PROTORECVEVENT pre = { 0 };
+ PROTORECVEVENT pre = {};
time_t t = time(0);
pre.timestamp = t;
pre.szMessage = (char*)msg;
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index 29dc9157f2..33b108f036 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -130,7 +130,7 @@ void CSkypeProto::LoadContactsAuth(NETLIBHTTPREQUEST *response, AsyncHttpRequest
DB::AUTH_BLOB blob(hContact, displayName.c_str(), nullptr, nullptr, skypeId.c_str(), reason.c_str());
- PROTORECVEVENT pre = { 0 };
+ PROTORECVEVENT pre = {};
pre.timestamp = time(0);
pre.lParam = blob.size();
pre.szMessage = blob;
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp
index a31a3c47c8..ec95703156 100644
--- a/protocols/Tox/src/tox_contacts.cpp
+++ b/protocols/Tox/src/tox_contacts.cpp
@@ -232,7 +232,7 @@ void CToxProto::OnFriendRequest(Tox*, const uint8_t *pubKey, const uint8_t *mess
DB::AUTH_BLOB blob(hContact, nullptr, nullptr, nullptr, (LPCSTR)address, (LPCSTR)message);
- PROTORECVEVENT pre = { 0 };
+ PROTORECVEVENT pre = {};
pre.timestamp = now();
pre.lParam = blob.size();
pre.szMessage = blob;