summaryrefslogtreecommitdiff
path: root/protocols/Facebook
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-12-29 14:17:52 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-12-29 14:17:52 +0300
commit9842d3db5d09d5b3fe560962f4a294f0edb57141 (patch)
treeda910153f669324196ead9082018010fe4b1b362 /protocols/Facebook
parent4e490ac4ac46eea7df6ef8a575c46206916c2164 (diff)
Facebook: simple MirVer detector
Diffstat (limited to 'protocols/Facebook')
-rw-r--r--protocols/Facebook/src/server.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
index 036652e978..930ac9c2b1 100644
--- a/protocols/Facebook/src/server.cpp
+++ b/protocols/Facebook/src/server.cpp
@@ -411,6 +411,16 @@ void FacebookProto::OnPublishMessage(FbThriftReader &rdr)
}
// new message arrived
+struct
+{
+ const char *szTag, *szClientVersion;
+}
+static facebookClients[] =
+{
+ { "source:titan:web", "Facebook (website)" },
+ { "app_id:256002347743983", "Facebook (Facebook Messenger)" }
+};
+
void FacebookProto::OnPublishPrivateMessage(const JSONNode &root)
{
auto &metadata = root["messageMetadata"];
@@ -433,6 +443,16 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root)
return;
}
+ for (auto &it : metadata["tags"]) {
+ auto *szTagName = it.name();
+ for (auto &cli : facebookClients) {
+ if (!mir_strcmp(szTagName, cli.szTag)) {
+ setString(pUser->hContact, "MirVer", cli.szClientVersion);
+ break;
+ }
+ }
+ }
+
__int64 actorFbId = _wtoi64(metadata["actorFbId"].as_mstring());
std::string szBody(root["body"].as_string());
@@ -442,10 +462,9 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root)
pre.timestamp = DWORD(_wtoi64(metadata["timestamp"].as_mstring()) / 1000);
pre.szMessage = (char *)szBody.c_str();
pre.szMsgId = (char *)szId.c_str();
-
- if (m_uid == actorFbId) {
+
+ if (m_uid == actorFbId)
pre.flags |= PREF_SENT;
- }
ProtoChainRecvMsg(pUser->hContact, &pre);
}