diff options
author | George Hazan <ghazan@miranda.im> | 2019-02-06 22:05:29 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-02-06 22:05:29 +0300 |
commit | e1c39a211d17ea4c04b62b5eca363194a66f5d11 (patch) | |
tree | 6840bd8f3765fe54c545c8f24b1cf509c0a9f057 | |
parent | 30e9a15c5487ea1c499806035083f3bf68cf1be3 (diff) |
ICQ10: fix for receiving stickers from history
-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); |