diff options
author | George Hazan <ghazan@miranda.im> | 2023-01-15 15:46:13 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-01-15 15:47:29 +0300 |
commit | 0c601c9ac661bd86975d1d408908c94e61b2fe33 (patch) | |
tree | 875aaff804120ad130710ebd8c449f26295a396c | |
parent | 4247352e1cda99e9a01feb91774528cf109b4436 (diff) |
fixes #3307 (Telegram: контакты часто залипают в статусе Away)
-rw-r--r-- | protocols/Telegram/src/mt_proto.h | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/server.cpp | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/protocols/Telegram/src/mt_proto.h b/protocols/Telegram/src/mt_proto.h index bf5c9e667b..9ab923de87 100644 --- a/protocols/Telegram/src/mt_proto.h +++ b/protocols/Telegram/src/mt_proto.h @@ -1,5 +1,7 @@ #pragma once
+#define STATUS_SWITCH_TIMEOUT 600
+
#define DBKEY_ID "id"
#define DBKEY_AVATAR_HASH "AvatarHash"
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 5828478802..2f40be0871 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -50,6 +50,7 @@ void CMTProto::LogOut() ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, ID_STATUS_OFFLINE);
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
+ m_impl.m_keepAlive.Stop();
setAllContactStatuses(ID_STATUS_OFFLINE, false);
}
@@ -66,7 +67,11 @@ void CMTProto::OnLoggedIn() SendQuery(new TD::terminateSession());
SendQuery(new TD::logOut(), &CMTProto::OnEndSession);
}
- else SendQuery(new TD::getChats(td::tl::unique_ptr<TD::chatListMain>(), 1000));
+ else {
+ m_impl.m_keepAlive.Start(1000);
+
+ SendQuery(new TD::getChats(td::tl::unique_ptr<TD::chatListMain>(), 1000));
+ }
}
///////////////////////////////////////////////////////////////////////////////
@@ -76,12 +81,12 @@ void CMTProto::SendKeepAlive() time_t now = time(0);
for (auto &it : m_arUsers) {
- if (it->m_timer1 && now - it->m_timer1 > 600) {
+ if (it->m_timer1 && now - it->m_timer1 > STATUS_SWITCH_TIMEOUT) {
it->m_timer1 = 0;
it->m_timer2 = now;
setWord(it->hContact, "Status", ID_STATUS_AWAY);
}
- else if (it->m_timer2 && now - it->m_timer2 > 600) {
+ else if (it->m_timer2 && now - it->m_timer2 > STATUS_SWITCH_TIMEOUT) {
it->m_timer2 = 0;
setWord(it->hContact, "Status", ID_STATUS_OFFLINE);
}
|