diff --git a/Telegram/SourceFiles/api/api_send_progress.cpp b/Telegram/SourceFiles/api/api_send_progress.cpp index e96b11da0..1335b6fb1 100644 --- a/Telegram/SourceFiles/api/api_send_progress.cpp +++ b/Telegram/SourceFiles/api/api_send_progress.cpp @@ -10,6 +10,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "history/history.h" #include "data/data_peer.h" +#include "data/data_user.h" +#include "base/unixtime.h" +#include "data/data_peer_values.h" #include "apiwrap.h" namespace Api { @@ -98,6 +101,9 @@ bool SendProgressManager::updated(const Key &key, bool doing) { } void SendProgressManager::send(const Key &key, int progress) { + if (skipRequest(key)) { + return; + } using Type = SendProgressType; const auto action = [&]() -> MTPsendMessageAction { const auto p = MTP_int(progress); @@ -135,6 +141,18 @@ void SendProgressManager::send(const Key &key, int progress) { } } +bool SendProgressManager::skipRequest(const Key &key) const { + const auto user = key.history->peer->asUser(); + if (!user) { + return false; + } else if (user->isSelf()) { + return true; + } else if (user->isBot() && !user->isSupport()) { + return true; + } + return !Data::OnlineTextActive(user->onlineTill, base::unixtime::now()); +} + void SendProgressManager::done( const MTPBool &result, mtpRequestId requestId) { diff --git a/Telegram/SourceFiles/api/api_send_progress.h b/Telegram/SourceFiles/api/api_send_progress.h index dc5dc7802..22bed6ac1 100644 --- a/Telegram/SourceFiles/api/api_send_progress.h +++ b/Telegram/SourceFiles/api/api_send_progress.h @@ -90,6 +90,8 @@ private: void send(const Key &key, int progress); void done(const MTPBool &result, mtpRequestId requestId); + [[nodiscard]] bool skipRequest(const Key &key) const; + const not_null _session; base::flat_map _requests; base::flat_map _updated;