diff options
author | George Hazan <george.hazan@gmail.com> | 2024-02-12 16:03:09 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-02-12 16:03:09 +0300 |
commit | e5e7844eb8306f84bb9de0024216d22a855a1816 (patch) | |
tree | ca126ee91e7a3098a9699bcde4796abf69f6fbd8 /protocols/Telegram | |
parent | f36247eab2f746a3ba996634e985907ee0ccdb7c (diff) |
Telegram: more checks for TD::deleteChatHistory parameters
Diffstat (limited to 'protocols/Telegram')
-rw-r--r-- | protocols/Telegram/src/server.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 96d941089b..e85332970f 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -440,8 +440,11 @@ INT_PTR CTelegramProto::SvcLoadServerHistory(WPARAM hContact, LPARAM) INT_PTR CTelegramProto::SvcEmptyServerHistory(WPARAM hContact, LPARAM lParam)
{
+ debugLogW(L"SvcEmptyServerHistory was called for cc=%d (%s)", (int)hContact, Clist_GetContactDisplayName(hContact));
+
if (auto *pUser = FindUser(GetId(hContact)))
- SendQuery(new TD::deleteChatHistory(pUser->chatId, false, (lParam & CDF_FOR_EVERYONE) != 0));
+ if (pUser->chatId != -1)
+ SendQuery(new TD::deleteChatHistory(pUser->chatId, false, (lParam & CDF_FOR_EVERYONE) != 0));
return 0;
}
@@ -593,20 +596,25 @@ void CTelegramProto::ProcessChatPosition(TD::updateChatPosition *pObj) return;
auto *pPos = (TD::chatPosition *)pObj->position_.get();
- if (pPos->list_) {
- auto *pList = (TD::chatListFolder *)pPos->list_.get();
-
- CMStringA szSetting(FORMAT, "ChatFilter%d", pList->chat_folder_id_);
- CMStringW wszGroup(getMStringW(szSetting));
- if (!wszGroup.IsEmpty()) {
- ptrW pwszExistingGroup(Clist_GetGroup(pUser->hContact));
- if (!pwszExistingGroup
- || (!pUser->isGroupChat && !mir_wstrcmp(pwszExistingGroup, m_wszDefaultGroup))
- || (pUser->isGroupChat && !mir_wstrcmp(pwszExistingGroup, ptrW(Chat_GetGroup())))) {
- CMStringW wszNewGroup(FORMAT, L"%s\\%s", (wchar_t *)m_wszDefaultGroup, wszGroup.c_str());
- Clist_GroupCreate(0, wszNewGroup);
- Clist_SetGroup(pUser->hContact, wszNewGroup);
- }
+ if (auto *pList = pPos->list_.get()) {
+ CMStringW wszGroup;
+ if (pList->get_id() == TD::chatListArchive::ID)
+ wszGroup = TranslateT("Archive");
+ else if (pList->get_id() == TD::chatListFolder::ID) {
+ CMStringA szSetting(FORMAT, "ChatFilter%d", ((TD::chatListFolder*)pList)->chat_folder_id_);
+ wszGroup = getMStringW(szSetting);
+ if (wszGroup.IsEmpty())
+ return;
+ }
+ else return;
+
+ ptrW pwszExistingGroup(Clist_GetGroup(pUser->hContact));
+ if (!pwszExistingGroup
+ || (!pUser->isGroupChat && !mir_wstrcmp(pwszExistingGroup, m_wszDefaultGroup))
+ || (pUser->isGroupChat && !mir_wstrcmp(pwszExistingGroup, ptrW(Chat_GetGroup())))) {
+ CMStringW wszNewGroup(FORMAT, L"%s\\%s", (wchar_t *)m_wszDefaultGroup, wszGroup.c_str());
+ Clist_GroupCreate(0, wszNewGroup);
+ Clist_SetGroup(pUser->hContact, wszNewGroup);
}
}
}
|