summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-03-01 12:20:23 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-03-01 12:20:23 +0300
commit670e1de41f7239592dc8e66fa3be3fc103ff0603 (patch)
tree7e82905d92f6edfdd1b25b0838ee3109b309b100 /protocols/Telegram/src
parentc00d709a545afb14400810f03a8d87d9f4e21302 (diff)
fixes #4257 (Telegram: ignore Main folder)
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r--protocols/Telegram/src/proto.h1
-rw-r--r--protocols/Telegram/src/server.cpp25
2 files changed, 17 insertions, 9 deletions
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 6b778deda6..c0bb072248 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -99,6 +99,7 @@ struct TG_USER : public MZeroedObject
int64_t id, chatId = -1;
MCONTACT hContact;
+ int folderId = -1;
bool isGroupChat, isBot, isForum, bLoadMembers, bStartChat, bInited;
CMStringA szAvatarHash;
CMStringW wszNick, wszFirstName, wszLastName;
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 12a2c6defe..828d8e19dd 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -625,19 +625,23 @@ void CTelegramProto::ProcessChatPosition(TD::updateChatPosition *pObj)
wszGroup = TranslateT("Archive");
break;
- case TD::chatListMain::ID:
- wszGroup = TranslateT("Main");
+ case TD::chatListMain::ID: // leave group empty
+ if (pUser->folderId != -1)
+ return;
break;
case TD::chatListFolder::ID:
{
- int iGroupId = ((TD::chatListFolder *)pList)->chat_folder_id_;
- CMStringA szSetting(FORMAT, "ChatFilter%d", iGroupId);
+ int iFolderId = ((TD::chatListFolder *)pList)->chat_folder_id_;
+ CMStringA szSetting(FORMAT, "ChatFilter%d", iFolderId);
wszGroup = getMStringW(szSetting);
if (wszGroup.IsEmpty()) {
- debugLogA("Empty group name for group #%d, ignored", iGroupId);
+ debugLogA("Empty group name for group #%d, ignored", iFolderId);
return;
}
+ if (wszGroup == "Unread")
+ return;
+ pUser->folderId = iFolderId;
}
break;
@@ -648,13 +652,16 @@ void CTelegramProto::ProcessChatPosition(TD::updateChatPosition *pObj)
MCONTACT hContact = GetRealContact(pUser);
ptrW pwszExistingGroup(Clist_GetGroup(hContact));
- debugLogW(L"Existing contact group %s, calculated %s", pwszExistingGroup.get(), wszGroup.c_str());
+ debugLogW(L"Existing contact group <%s>, calculated <%s>", pwszExistingGroup.get(), wszGroup.c_str());
- if (!pwszExistingGroup
- || (!pUser->isGroupChat && !mir_wstrcmp(pwszExistingGroup, m_wszDefaultGroup))
+ wchar_t *pwszDefaultGroup = m_wszDefaultGroup;
+ if (!pwszExistingGroup || pUser->isForum
+ || !mir_wstrncmp(pwszExistingGroup, pwszDefaultGroup, mir_wstrlen(pwszDefaultGroup))
|| (pUser->isGroupChat && !mir_wstrcmp(pwszExistingGroup, ptrW(Chat_GetGroup()))))
{
- CMStringW wszNewGroup(FORMAT, L"%s\\%s", (wchar_t *)m_wszDefaultGroup, wszGroup.c_str());
+ CMStringW wszNewGroup(pwszDefaultGroup);
+ if (!wszGroup.IsEmpty())
+ wszNewGroup.AppendFormat(L"\\%s", wszGroup.c_str());
if (pUser->isForum)
wszNewGroup.AppendFormat(L"\\%s", pUser->wszNick.c_str());