summaryrefslogtreecommitdiff
path: root/protocols/Facebook
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-12-29 15:30:24 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-12-29 15:30:24 +0300
commit58c6693dd4ef206b357d137ed38e0ec5ea3d94e7 (patch)
tree3546382af5ed628428fbfd468b3b0a751d143926 /protocols/Facebook
parent9842d3db5d09d5b3fe560962f4a294f0edb57141 (diff)
Facebook: read receipts support
Diffstat (limited to 'protocols/Facebook')
-rw-r--r--protocols/Facebook/src/proto.h1
-rw-r--r--protocols/Facebook/src/server.cpp32
2 files changed, 30 insertions, 3 deletions
diff --git a/protocols/Facebook/src/proto.h b/protocols/Facebook/src/proto.h
index b25cd31d5c..c6e2ee24a8 100644
--- a/protocols/Facebook/src/proto.h
+++ b/protocols/Facebook/src/proto.h
@@ -442,6 +442,7 @@ public:
}
void OnPublishPrivateMessage(const JSONNode &json);
+ void OnPublishReadReceipt(const JSONNode &json);
void OnPublishSentMessage(const JSONNode &json);
//////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
index 930ac9c2b1..d24435c3fb 100644
--- a/protocols/Facebook/src/server.cpp
+++ b/protocols/Facebook/src/server.cpp
@@ -373,8 +373,9 @@ struct
}
static MsgHandlers[] =
{
- { "deltaNewMessage", &FacebookProto::OnPublishPrivateMessage },
- { "deltaSentMessage", &FacebookProto::OnPublishSentMessage }
+ { "deltaNewMessage", &FacebookProto::OnPublishPrivateMessage },
+ { "deltaSentMessage", &FacebookProto::OnPublishSentMessage },
+ { "deltaReadReceipt", &FacebookProto::OnPublishReadReceipt },
};
void FacebookProto::OnPublishMessage(FbThriftReader &rdr)
@@ -469,6 +470,30 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root)
ProtoChainRecvMsg(pUser->hContact, &pre);
}
+// read notification
+void FacebookProto::OnPublishReadReceipt(const JSONNode &root)
+{
+ CMStringA wszUserId(root["threadKey"]["otherUserFbId"].as_mstring());
+ auto *pUser = FindUser(_atoi64(wszUserId));
+ if (pUser == nullptr) {
+ debugLogA("Message from unknown contact %s, ignored", wszUserId.c_str());
+ return;
+ }
+
+ DWORD timestamp = _wtoi64(root["watermarkTimestampMs"].as_mstring());
+ for (MEVENT ev = db_event_firstUnread(pUser->hContact); ev != 0; ev = db_event_next(pUser->hContact, ev)) {
+ DBEVENTINFO dbei = {};
+ if (db_event_get(ev, &dbei))
+ continue;
+
+ if (dbei.timestamp > timestamp)
+ break;
+
+ if (!dbei.markedRead())
+ db_event_markRead(pUser->hContact, ev);
+ }
+}
+
// my own message was sent
void FacebookProto::OnPublishSentMessage(const JSONNode &root)
{
@@ -484,10 +509,11 @@ void FacebookProto::OnPublishSentMessage(const JSONNode &root)
return;
}
- for (auto &it : arOwnMessages)
+ for (auto &it : arOwnMessages) {
if (it->msgId == offlineId) {
ProtoBroadcastAck(pUser->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)it->reqId, (LPARAM)szId.c_str());
arOwnMessages.remove(arOwnMessages.indexOf(&it));
break;
}
+ }
}