diff options
author | ikeblaster <ike@thez.info> | 2020-02-27 23:57:57 +0100 |
---|---|---|
committer | ikeblaster <ike@thez.info> | 2020-02-27 23:58:04 +0100 |
commit | 7869990f380805939298ef3d59e6ccf9b62bc834 (patch) | |
tree | d60cb357aa4700a74edaa2754b6f15770c266342 /protocols/Facebook | |
parent | afc8206f4fc571d4923a922abd493882cebfe963 (diff) |
Facebook: group chat initialization improvement
Chat_GetUserInfo is not usable since we have no "info" saved for users (=always returns nullptr).
Diffstat (limited to 'protocols/Facebook')
-rw-r--r-- | protocols/Facebook/src/proto.h | 6 | ||||
-rw-r--r-- | protocols/Facebook/src/server.cpp | 21 |
2 files changed, 16 insertions, 11 deletions
diff --git a/protocols/Facebook/src/proto.h b/protocols/Facebook/src/proto.h index 6bf94d6060..2d42a4b111 100644 --- a/protocols/Facebook/src/proto.h +++ b/protocols/Facebook/src/proto.h @@ -343,15 +343,17 @@ public: struct FacebookUser { - FacebookUser(__int64 _p1, MCONTACT _p2, bool _p3 = false) : + FacebookUser(__int64 _p1, MCONTACT _p2, bool _p3 = false, bool _p4 = false) : id(_p1), hContact(_p2), - bIsChat(_p3) + bIsChat(_p3), + bIsChatInitialized(_p4) {} __int64 id; MCONTACT hContact; bool bIsChat; + bool bIsChatInitialized; }; ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp index faa8032d7b..506e59969c 100644 --- a/protocols/Facebook/src/server.cpp +++ b/protocols/Facebook/src/server.cpp @@ -238,11 +238,13 @@ FacebookUser* FacebookProto::RefreshThread(JSONNode& n) { auto* user = FindUser(userId); if (user == nullptr) { - user = new FacebookUser(userId, si->hContact, true); + user = new FacebookUser(userId, si->hContact, true, true); m_users.insert(user); } - else + else { user->hContact = si->hContact; + user->bIsChatInitialized = true; + } return user; } @@ -621,15 +623,16 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root) CMStringW wszUserId; bool bIsChat; auto *pUser = UserFromJson(metadata, wszUserId, bIsChat); + + if (!bIsChat && pUser == nullptr) + pUser = AddContact(wszUserId, true); + else if (bIsChat && (pUser == nullptr || !pUser->bIsChatInitialized)) // chat room does not exists or is not initialized + pUser = RefreshThread(wszUserId); + if (pUser == nullptr) { - if (bIsChat) - pUser = RefreshThread(wszUserId); - else - pUser = AddContact(wszUserId, true); + debugLogA("User not found and adding failed, event skipped"); + return; } - else if (bIsChat && Chat_GetUserInfo(m_szModuleName, wszUserId) == nullptr) // user already exists, but room is not initialized - RefreshThread(wszUserId); - for (auto &it : metadata["tags"]) { auto *szTagName = it.name(); |