summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Facebook/src/proto.h6
-rw-r--r--protocols/Facebook/src/server.cpp21
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();