diff options
-rw-r--r-- | protocols/FacebookRM/src/chat.cpp | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 31 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 14 |
3 files changed, 25 insertions, 23 deletions
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index e516b6aec7..f2108e48a6 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -52,7 +52,8 @@ void FacebookProto::UpdateChat(const TCHAR *tchat_id, const char *id, const char // TODO: keep it here or move it somewhere else? std::map<std::tstring, facebook_chatroom*>::iterator chatroom = facy.chat_rooms.find(tchat_id); if (chatroom != facy.chat_rooms.end()) { - chatroom->second->message_readers.clear(); + chatroom->second->message_readers.clear(); // TODO: move this to erase_reader method? + facy.erase_reader(ChatIDToHContact(std::tstring(tchat_id))); } } diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 7ef4b78518..20e1b937e3 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -438,9 +438,14 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo continue; time_t timestamp = utils::time::from_string(json_as_pstring(time)); + MCONTACT hContact = NULL; JSONNODE *threadid = json_get(it, "tid"); - if (threadid != NULL) { // multi user chat + if (threadid == NULL) { + // classic contact + hContact = proto->ContactIDToHContact(json_as_pstring(reader)); + } else { + // multi user chat if (!proto->m_enableChat) continue; @@ -469,29 +474,13 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo std::tstring tname = _A2T(participant->second.c_str(), CP_UTF8); chatroom->message_readers += utils::text::prepare_name(tname, true); - MCONTACT hChatContact = proto->ChatIDToHContact(tid); - if (!hChatContact) - continue; - - StatusTextData st = { 0 }; - st.cbSize = sizeof(st); - st.hIcon = Skin_GetIconByHandle(GetIconHandle("read")); - - TCHAR ttime[64]; - _tcsftime(ttime, SIZEOF(ttime), _T("%X"), localtime(×tamp)); - - mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("Message read: %s by %s"), ttime, chatroom->message_readers.c_str()); - - CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact, (LPARAM)&st); + hContact = proto->ChatIDToHContact(tid); } } } - else { // classic contact - MCONTACT hContact = proto->ContactIDToHContact(json_as_pstring(reader)); - if (hContact) { - proto->facy.insert_reader(hContact, timestamp); - } - } + + if (hContact) + proto->facy.insert_reader(hContact, timestamp); } else if (t == "deliver") { // inbox message (multiuser or direct) diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index c8244b87e7..47b34e8b39 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -1109,7 +1109,19 @@ void FacebookProto::MessageRead(MCONTACT hContact) StatusTextData st = { 0 }; st.cbSize = sizeof(st); st.hIcon = Skin_GetIconByHandle(GetIconHandle("read")); - mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("Message read: %s"), ttime); + + if (isChatRoom(hContact)) { + // Get threadId to find chatroom in map + std::tstring tid = ptrT(getTStringA(hContact, FACEBOOK_KEY_TID)); + std::map<std::tstring, facebook_chatroom*>::iterator it = facy.chat_rooms.find(tid); + + // Get readers from chatroom + TCHAR *treaders = (it != facy.chat_rooms.end() ? it->second->message_readers.c_str() : _T("???")); + + mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("Message read: %s by %s"), ttime, treaders); + } else { + mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("Message read: %s"), ttime); + } CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st); } |