summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Facebook/src/proto.h2
-rw-r--r--protocols/Facebook/src/server.cpp69
-rw-r--r--protocols/Facebook/src/version.h2
3 files changed, 68 insertions, 5 deletions
diff --git a/protocols/Facebook/src/proto.h b/protocols/Facebook/src/proto.h
index 2d64745784..ff7691f01d 100644
--- a/protocols/Facebook/src/proto.h
+++ b/protocols/Facebook/src/proto.h
@@ -503,6 +503,8 @@ public:
void OnPublishReadReceipt(const JSONNode &json);
void OnPublishSentMessage(const JSONNode &json);
void OnPublishThreadName(const JSONNode &json);
+ void OnPublishChatJoin(const JSONNode &json);
+ void OnPublishChatLeave(const JSONNode &json);
//////////////////////////////////////////////////////////////////////////////////////
// options
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
index 357c9d0c6f..7978697511 100644
--- a/protocols/Facebook/src/server.cpp
+++ b/protocols/Facebook/src/server.cpp
@@ -551,10 +551,12 @@ struct
}
static MsgHandlers[] =
{
- { "deltaNewMessage", &FacebookProto::OnPublishPrivateMessage },
- { "deltaThreadName", &FacebookProto::OnPublishThreadName },
- { "deltaSentMessage", &FacebookProto::OnPublishSentMessage },
- { "deltaReadReceipt", &FacebookProto::OnPublishReadReceipt },
+ { "deltaNewMessage", &FacebookProto::OnPublishPrivateMessage },
+ { "deltaThreadName", &FacebookProto::OnPublishThreadName },
+ { "deltaSentMessage", &FacebookProto::OnPublishSentMessage },
+ { "deltaReadReceipt", &FacebookProto::OnPublishReadReceipt },
+ { "deltaParticipantsAddedToGroupThread", &FacebookProto::OnPublishChatJoin },
+ { "deltaParticipantLeftGroupThread", &FacebookProto::OnPublishChatLeave },
};
void FacebookProto::OnPublishMessage(FbThriftReader &rdr)
@@ -873,6 +875,65 @@ void FacebookProto::OnPublishThreadName(const JSONNode &root)
delSetting(pUser->hContact, DBKEY_NICK);
}
+// user joined chat
+void FacebookProto::OnPublishChatJoin(const JSONNode &root)
+{
+ auto &metadata = root["messageMetadata"];
+ __int64 offlineId = _wtoi64(metadata["offlineThreadingId"].as_mstring());
+ if (!offlineId) {
+ debugLogA("We care about messages only, event skipped");
+ return;
+ }
+
+ bool bIsChat;
+ CMStringW wszUserId;
+ auto *pUser = UserFromJson(metadata, wszUserId, bIsChat);
+ if (!bIsChat || pUser == nullptr)
+ return;
+
+ CMStringW wszText(metadata["adminText"].as_mstring());
+ for (auto &it : root["addedParticipants"]) {
+ CMStringW wszNick(it["fullName"].as_mstring()), wszId(it["userFbId"].as_mstring());
+
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_JOIN };
+ gce.pszID.w = wszUserId;
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.pszNick.w = wszNick;
+ gce.pszUID.w = wszId;
+ gce.pszText.w = wszText;
+ gce.time = time(0);
+ gce.bIsMe = _wtoi64(wszId) == m_uid;
+ Chat_Event(&gce);
+ }
+}
+
+// user left chat
+void FacebookProto::OnPublishChatLeave(const JSONNode &root)
+{
+ auto &metadata = root["messageMetadata"];
+ __int64 offlineId = _wtoi64(metadata["offlineThreadingId"].as_mstring());
+ if (!offlineId) {
+ debugLogA("We care about messages only, event skipped");
+ return;
+ }
+
+ bool bIsChat;
+ CMStringW wszUserId;
+ auto *pUser = UserFromJson(metadata, wszUserId, bIsChat);
+ if (!bIsChat || pUser == nullptr)
+ return;
+
+ CMStringW wszText(metadata["adminText"].as_mstring()), wszId(root["leftParticipantFbId"].as_mstring());
+ GCEVENT gce = { m_szModuleName, 0, GC_EVENT_PART };
+ gce.pszID.w = wszUserId;
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.pszUID.w = wszId;
+ gce.pszText.w = wszText;
+ gce.time = time(0);
+ gce.bIsMe = _wtoi64(wszId) == m_uid;
+ Chat_Event(&gce);
+}
+
// read notification
void FacebookProto::OnPublishReadReceipt(const JSONNode &root)
{
diff --git a/protocols/Facebook/src/version.h b/protocols/Facebook/src/version.h
index fbca217963..b554ac7a8b 100644
--- a/protocols/Facebook/src/version.h
+++ b/protocols/Facebook/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 9
+#define __BUILD_NUM 10
#include <stdver.h>