summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-11-14 16:02:02 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-11-14 16:02:02 +0300
commitd19d86665efa3dda7a16089d4f7bf469fe833aab (patch)
tree607b924c517cdc27aca40bef6a2f007a143894ff
parent1c5f9fca3e84bcddff36a70fbce0c48d9eb78be3 (diff)
fixes #3921 (Telegram: невозможно отключить фейковые статусы)
-rw-r--r--protocols/Telegram/src/proto.h2
-rw-r--r--protocols/Telegram/src/server.cpp21
2 files changed, 15 insertions, 8 deletions
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 225e7b7622..c8a48d844e 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -1,7 +1,5 @@
#pragma once
-#define STATUS_SWITCH_TIMEOUT 600
-
#define DBKEY_ID "id"
#define DBKEY_COMPAT "Compatibility"
#define DBKEY_AUTHORIZED "Authorized"
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 3aad877837..751fd69a94 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -106,14 +106,20 @@ void CTelegramProto::OnLoggedIn()
void CTelegramProto::SendKeepAlive()
{
time_t now = time(0);
+ int iDiff1 = m_iTimeDiff1, iDiff2 = m_iTimeDiff2;
for (auto &it : m_arUsers) {
- if (it->m_timer1 && now - it->m_timer1 > STATUS_SWITCH_TIMEOUT) {
+ if (it->m_timer1 && now - it->m_timer1 > iDiff1) {
it->m_timer1 = 0;
- it->m_timer2 = now;
- setWord(it->hContact, "Status", ID_STATUS_NA);
+
+ // if the second status is set in the options, enable the second timer
+ if (m_iTimeDiff2) {
+ it->m_timer2 = now;
+ setWord(it->hContact, "Status", m_iStatus2);
+ }
+ else setWord(it->hContact, "Status", ID_STATUS_OFFLINE);
}
- else if (it->m_timer2 && now - it->m_timer2 > STATUS_SWITCH_TIMEOUT) {
+ else if (it->m_timer2 && now - it->m_timer2 > iDiff2) {
it->m_timer2 = 0;
setWord(it->hContact, "Status", ID_STATUS_OFFLINE);
}
@@ -832,8 +838,11 @@ void CTelegramProto::ProcessStatus(TD::updateUserStatus *pObj)
case TD::userStatusRecently::ID:
case TD::userStatusOffline::ID:
- setWord(pUser->hContact, "Status", ID_STATUS_AWAY);
- pUser->m_timer1 = time(0);
+ if (m_iTimeDiff1) {
+ setWord(pUser->hContact, "Status", m_iStatus1);
+ pUser->m_timer1 = time(0);
+ }
+ else setWord(pUser->hContact, "Status", ID_STATUS_OFFLINE);
break;
default: