summaryrefslogtreecommitdiff
path: root/protocols/Facebook/src/server.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-12-24 19:13:55 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-12-24 19:13:55 +0300
commit146138489431bfea31bbeb285ba2dc15b2bc458b (patch)
tree79d7f14d4cb2f96f3c257500ebd5d61609279ffa /protocols/Facebook/src/server.cpp
parent2e7a7b005e21064590380cc75d862867c1d19525 (diff)
Facebook: support for typing notifications
Diffstat (limited to 'protocols/Facebook/src/server.cpp')
-rw-r--r--protocols/Facebook/src/server.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
index 494c951ead..3d57ae2cb9 100644
--- a/protocols/Facebook/src/server.cpp
+++ b/protocols/Facebook/src/server.cpp
@@ -218,11 +218,13 @@ void FacebookProto::OnPublish(const char *topic, const uint8_t *p, size_t cbLen)
rdr.reset(cbLen, (void*)p);
if (!strcmp(topic, "/t_p"))
- OnPublishP(rdr);
+ OnPublishPresence(rdr);
+ else if (!strcmp(topic, "/orca_typing_notifications"))
+ OnPublishUtn(rdr);
}
-void FacebookProto::OnPublishP(FbThriftReader &rdr)
+void FacebookProto::OnPublishPresence(FbThriftReader &rdr)
{
char *str;
rdr.readStr(str);
@@ -284,3 +286,13 @@ void FacebookProto::OnPublishP(FbThriftReader &rdr)
rdr.readByte(fieldType);
assert(fieldType == FB_THRIFT_TYPE_STOP);
}
+
+void FacebookProto::OnPublishUtn(FbThriftReader &rdr)
+{
+ JSONNode root = JSONNode::parse((const char *)rdr.data());
+ auto *pUser = FindUser(_wtoi64(root["sender_fbid"].as_mstring()));
+ if (pUser != nullptr) {
+ int length = (root["state"].as_int() == 0) ? PROTOTYPE_CONTACTTYPING_OFF : 60;
+ CallService(MS_PROTO_CONTACTISTYPING, pUser->hContact, length);
+ }
+}