mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-10-27 15:25:58 +00:00
Don't send typings to bots and offline users.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user