diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/ICQ-WIM/src/poll.cpp | 12 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 10 |
2 files changed, 15 insertions, 7 deletions
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index 7360544ec5..b25dd4c71e 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -152,8 +152,18 @@ void CIcqProto::ProcessHistData(const JSONNode &ev) } // or load missing messages if any - if (ev["unreadCnt"].as_int() > 0) + switch (ev["unreadCnt"].as_int()) { + case 0: break; + case 1: + if (!IsChat(wszId)) + for (auto &it : ev["tail"]["messages"]) + ParseMessage(hContact, lastMsgId, it, false); + setId(hContact, DB_KEY_LASTMSGID, lastMsgId); + break; + + default: RetrieveUserHistory(hContact, lastMsgId); + } // check remote read if (g_bMessageState) { diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index be02a2ffe8..06a2f12d33 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -327,11 +327,9 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo lastMsgId = msgId; CMStringW wszText; - CMStringW type(it["mediaType"].as_mstring()); - if (type == "text" || type.IsEmpty()) - wszText = it["text"].as_mstring(); - else if (type == "sticker") { - CMStringW wszUrl, wszSticker(it["sticker"]["id"].as_mstring()); + const JSONNode &sticker = it["sticker"]; + if (sticker) { + CMStringW wszUrl, wszSticker(sticker["id"].as_mstring()); int iCollectionId, iStickerId; if (2 == swscanf(wszSticker, L"ext:%d:sticker:%d", &iCollectionId, &iStickerId)) wszUrl.Format(L"https://c.icq.com/store/stickers/%d/%d/medium", iCollectionId, iStickerId); @@ -339,7 +337,7 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo wszUrl = TranslateT("Unknown sticker"); wszText.Format(L"%s\n%s", TranslateT("User sent a sticker:"), wszUrl.c_str()); } - else return; + else wszText = it["text"].as_mstring(); int iMsgTime = (bFromHistory) ? it["time"].as_int() : time(0); |