diff options
author | George Hazan <george.hazan@gmail.com> | 2025-04-02 19:50:28 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2025-04-02 19:50:28 +0300 |
commit | 0f43b99e7dbdeaa8cba7d2c17415782f0f9b7cb3 (patch) | |
tree | 04259a0d31d934eb2b14c9f22c26fcac03bc4f9d /protocols/Telegram/src | |
parent | 2523968f8b92f7c5ae2192c2b62d1deaf0c4f8eb (diff) |
fixes #4941 (Telegram: удаленное локально событие невозможно перезапросить с сервера)
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r-- | protocols/Telegram/src/proto.h | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/server.cpp | 35 |
2 files changed, 14 insertions, 23 deletions
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index 1cf276323e..2ec142edca 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -101,7 +101,7 @@ struct TG_USER : public MZeroedObject int64_t id, chatId = -1, forumId = -1; MCONTACT hContact; - int folderId = -1, nHistoryChunks, nTopics; + int folderId = -1, nTopics; bool isGroupChat, isChannel, isBot, isForum, bLoadMembers, bStartChat, bInited, bDelOwn = true, bDelAll = true; CMStringA szAvatarHash; CMStringW wszNick, wszFirstName, wszLastName; diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index e3f82dcd5b..4e783c06a6 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -456,6 +456,12 @@ void CTelegramProto::OnGetHistory(td::ClientManager::Response &response, void *p auto *pUser = (TG_USER *)pUserInfo;
TD::int53 lastMsgId = INT64_MAX;
auto *pMessages = (TD::messages *)response.object.get();
+ if (pMessages->messages_.size() == 0) {
+ if (pUser->isForum)
+ delete pUser;
+ return;
+ }
+
for (auto &it : pMessages->messages_) {
auto *pMsg = it.get();
if (pMsg->id_ < lastMsgId)
@@ -489,27 +495,15 @@ void CTelegramProto::OnGetHistory(td::ClientManager::Response &response, void *p db_event_add(GetRealContact(pUser), &dbei);
}
- pUser->nHistoryChunks--;
-
- if (pUser->isForum) {
- if (lastMsgId != INT64_MAX && pUser->nHistoryChunks > 0)
- SendQuery(new TD::getMessageThreadHistory(pUser->chatId, lastMsgId, lastMsgId, 0, 100), &CTelegramProto::OnGetHistory, pUser);
- else
- delete pUser;
- }
- else if (lastMsgId != INT64_MAX && pUser->nHistoryChunks > 0)
+ // fetch next portion
+ if (pUser->isForum)
+ SendQuery(new TD::getMessageThreadHistory(pUser->chatId, lastMsgId, lastMsgId, 0, 100), &CTelegramProto::OnGetHistory, pUser);
+ else
SendQuery(new TD::getChatHistory(pUser->chatId, lastMsgId, 0, 100, false), &CTelegramProto::OnGetHistory, pUser);
}
INT_PTR CTelegramProto::SvcLoadServerHistory(WPARAM hContact, LPARAM)
{
- TD::int53 lastMsgId = 0;
-
- if (MEVENT hEvent = db_event_first(hContact)) {
- DB::EventInfo dbei(hEvent, false);
- lastMsgId = dbei2id(dbei);
- }
-
auto userId = GetId(hContact);
if (TD::int53 threadId = GetId(hContact, DBKEY_THREAD)) {
@@ -517,16 +511,13 @@ INT_PTR CTelegramProto::SvcLoadServerHistory(WPARAM hContact, LPARAM) auto *pUser = new TG_USER(-1, hContact, true);
pUser->chatId = userId;
pUser->isForum = pUser->isGroupChat = true;
- pUser->nHistoryChunks = 5;
- SendQuery(new TD::getMessageThreadHistory(pUser->chatId, lastMsgId, lastMsgId, 0, 100), &CTelegramProto::OnGetHistory, pUser);
+ SendQuery(new TD::getMessageThreadHistory(pUser->chatId, 0, 0, 0, 100), &CTelegramProto::OnGetHistory, pUser);
return 0;
}
}
- if (auto *pUser = FindUser(userId)) {
- pUser->nHistoryChunks = 5;
- SendQuery(new TD::getChatHistory(pUser->chatId, lastMsgId, 0, 100, false), &CTelegramProto::OnGetHistory, pUser);
- }
+ if (auto *pUser = FindUser(userId))
+ SendQuery(new TD::getChatHistory(pUser->chatId, 0, 0, 100, false), &CTelegramProto::OnGetHistory, pUser);
return 0;
}
|