diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 7cacf81bb..6ec8086a0 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -10887,6 +10887,11 @@ Result ContactsManager::get_bot_data(UserId user_id) const { return bot_data; } +bool ContactsManager::is_user_status_exact(UserId user_id) const { + auto u = get_user(user_id); + return u != nullptr && !u->is_deleted && !u->is_bot && u->was_online > 0; +} + bool ContactsManager::can_report_user(UserId user_id) const { auto u = get_user(user_id); return u != nullptr && !u->is_deleted && u->is_bot && !u->is_support; diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index b91edec81..94a0c4013 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -393,6 +393,8 @@ class ContactsManager : public Actor { bool is_user_bot(UserId user_id) const; Result get_bot_data(UserId user_id) const TD_WARN_UNUSED_RESULT; + bool is_user_status_exact(UserId user_id) const; + bool can_report_user(UserId user_id) const; bool have_user(UserId user_id) const; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 4b209a020..5fb8c6372 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -24035,7 +24035,21 @@ void MessagesManager::send_dialog_action(DialogId dialog_id, const tl_object_ptr return promise.set_value(Unit()); } - if (dialog_id.get_type() == DialogType::SecretChat) { + auto dialog_type = dialog_id.get_type(); + if (dialog_type == DialogType::User || dialog_type == DialogType::SecretChat) { + UserId user_id = dialog_type == DialogType::User + ? dialog_id.get_user_id() + : td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id()); + if (!user_id.is_valid() || td_->contacts_manager_->is_user_bot(user_id) || + td_->contacts_manager_->is_user_deleted(user_id)) { + return promise.set_value(Unit()); + } + if (!td_->auth_manager_->is_bot() && !td_->contacts_manager_->is_user_status_exact(user_id)) { + return promise.set_value(Unit()); + } + } + + if (dialog_type == DialogType::SecretChat) { tl_object_ptr send_action; switch (action->get_id()) { case td_api::chatActionCancel::ID: