diff options
author | George Hazan <ghazan@miranda.im> | 2019-12-24 19:13:55 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-12-24 19:13:55 +0300 |
commit | 146138489431bfea31bbeb285ba2dc15b2bc458b (patch) | |
tree | 79d7f14d4cb2f96f3c257500ebd5d61609279ffa /protocols/Facebook | |
parent | 2e7a7b005e21064590380cc75d862867c1d19525 (diff) |
Facebook: support for typing notifications
Diffstat (limited to 'protocols/Facebook')
-rw-r--r-- | protocols/Facebook/src/proto.h | 3 | ||||
-rw-r--r-- | protocols/Facebook/src/server.cpp | 16 |
2 files changed, 16 insertions, 3 deletions
diff --git a/protocols/Facebook/src/proto.h b/protocols/Facebook/src/proto.h index 7d5bedc911..a8ba6c6d39 100644 --- a/protocols/Facebook/src/proto.h +++ b/protocols/Facebook/src/proto.h @@ -370,7 +370,8 @@ class FacebookProto : public PROTO<FacebookProto> void MqttSend(const MqttMessage &payload); void OnPublish(const char *str, const uint8_t *payLoad, size_t cbLen); - void OnPublishP(FbThriftReader &rdr); + void OnPublishPresence(FbThriftReader &rdr); + void OnPublishUtn(FbThriftReader &rdr); HNETLIBCONN m_mqttConn; 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); + } +} |