diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 72d97323e..3376e375a 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -29886,7 +29886,7 @@ void MessagesManager::do_send_screenshot_taken_notification_message(DialogId dia } void MessagesManager::share_dialog_with_bot(FullMessageId full_message_id, int32 button_id, DialogId shared_dialog_id, - bool only_check, Promise &&promise) { + bool expect_user, bool only_check, Promise &&promise) { const Message *m = get_message_force(full_message_id, "share_dialog_with_bot"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); @@ -29900,6 +29900,9 @@ void MessagesManager::share_dialog_with_bot(FullMessageId full_message_id, int32 return promise.set_error(Status::Error(400, "Shared chat not found")); } } else { + if (!expect_user) { + return promise.set_error(Status::Error(400, "Wrong chat type")); + } if (!td_->contacts_manager_->have_user(shared_dialog_id.get_user_id())) { return promise.set_error(Status::Error(400, "Shared user not found")); } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 3197a5229..d0c04ce65 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -467,8 +467,8 @@ class MessagesManager final : public Actor { Status send_screenshot_taken_notification_message(DialogId dialog_id); - void share_dialog_with_bot(FullMessageId full_message_id, int32 button_id, DialogId shared_dialog_id, bool only_check, - Promise &&promise); + void share_dialog_with_bot(FullMessageId full_message_id, int32 button_id, DialogId shared_dialog_id, + bool expect_user, bool only_check, Promise &&promise); Result add_local_message(DialogId dialog_id, td_api::object_ptr &&sender, MessageId reply_to_message_id, bool disable_notification, diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 831016a35..7bf8ac9f0 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7684,7 +7684,7 @@ void Td::on_request(uint64 id, const td_api::shareUserWithBot &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); messages_manager_->share_dialog_with_bot({DialogId(request.chat_id_), MessageId(request.message_id_)}, - request.button_id_, DialogId(UserId(request.shared_user_id_)), + request.button_id_, DialogId(UserId(request.shared_user_id_)), true, request.only_check_, std::move(promise)); } @@ -7692,8 +7692,8 @@ void Td::on_request(uint64 id, const td_api::shareChatWithBot &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); messages_manager_->share_dialog_with_bot({DialogId(request.chat_id_), MessageId(request.message_id_)}, - request.button_id_, DialogId(request.shared_chat_id_), request.only_check_, - std::move(promise)); + request.button_id_, DialogId(request.shared_chat_id_), false, + request.only_check_, std::move(promise)); } void Td::on_request(uint64 id, td_api::getInlineQueryResults &request) {