summaryrefslogtreecommitdiff
path: root/protocols/Facebook/src
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/Facebook/src
parent6ef65121fed3c38c467238a08bf96bf98a23d7d8 (diff)
SRMM: better support for group chats in database
Diffstat (limited to 'protocols/Facebook/src')
-rw-r--r--protocols/Facebook/src/proto.cpp2
-rw-r--r--protocols/Facebook/src/server.cpp41
2 files changed, 12 insertions, 31 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