From 7869990f380805939298ef3d59e6ccf9b62bc834 Mon Sep 17 00:00:00 2001 From: ikeblaster Date: Thu, 27 Feb 2020 23:57:57 +0100 Subject: Facebook: group chat initialization improvement Chat_GetUserInfo is not usable since we have no "info" saved for users (=always returns nullptr). --- protocols/Facebook/src/server.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'protocols/Facebook/src/server.cpp') 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(); -- cgit v1.2.3