summaryrefslogtreecommitdiff
path: root/protocols/Facebook/src
diff options
context:
space:
mode:
authorikeblaster <ike@thez.info>2019-12-28 21:35:01 +0100
committerikeblaster <ike@thez.info>2019-12-28 21:35:01 +0100
commit94a442068bb21f543cc8f3efb864b8d3521160af (patch)
treee23b23b2638087bf53d262f6ff09d67a0bbd4dbc /protocols/Facebook/src
parent9406569f424b79ff8186f7608cb479e2dbf3a420 (diff)
Facebook: handling "own" messages sent via other clients
Logging messages written by myself (via other clients) into correct chats. Implementation of threads/rooms/group chats (same thing) needed.
Diffstat (limited to 'protocols/Facebook/src')
-rw-r--r--protocols/Facebook/src/server.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
index 6cfd025ea4..ab5ffb46c8 100644
--- a/protocols/Facebook/src/server.cpp
+++ b/protocols/Facebook/src/server.cpp
@@ -420,13 +420,21 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root)
return;
}
- CMStringA wszUserId(metadata["actorFbId"].as_mstring());
- auto *pUser = FindUser(_atoi64(wszUserId));
+ __int64 otherUserFbId = _wtoi64(metadata["threadKey"]["otherUserFbId"].as_mstring());
+ if (!otherUserFbId) {
+ // TODO: handling thread/room/groupchat messages
+ debugLogA("We can't handle group chats at the moment, ignored");
+ return;
+ }
+
+ auto *pUser = FindUser(otherUserFbId);
if (pUser == nullptr) {
- debugLogA("Message from unknown contact %s, ignored", wszUserId.c_str());
+ debugLogA("Message from unknown contact %lu, ignored", otherUserFbId);
return;
}
+ __int64 actorFbId = _wtoi64(metadata["actorFbId"].as_mstring());
+
std::string szBody(root["body"].as_string());
std::string szId(metadata["messageId"].as_string());
@@ -434,6 +442,11 @@ 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) {
+ pre.flags |= PREF_SENT;
+ }
+
ProtoChainRecvMsg(pUser->hContact, &pre);
}