Do not send chat actions to bots, deleted users and users with hidden online status.
GitOrigin-RevId: 8bd7c272b34ae6d977e58e89f0e76a158f02f150
This commit is contained in:
parent
7e47ef07df
commit
0594b9e795
@ -10887,6 +10887,11 @@ Result<BotData> 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;
|
||||
|
@ -393,6 +393,8 @@ class ContactsManager : public Actor {
|
||||
bool is_user_bot(UserId user_id) const;
|
||||
Result<BotData> 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;
|
||||
|
@ -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<secret_api::SendMessageAction> send_action;
|
||||
switch (action->get_id()) {
|
||||
case td_api::chatActionCancel::ID:
|
||||
|
Loading…
Reference in New Issue
Block a user