Add some secret chat checks.

This commit is contained in:
levlam 2023-03-22 15:05:05 +03:00
parent dbf66634cf
commit 4a0f5011cb
5 changed files with 8 additions and 3 deletions

View File

@ -6592,7 +6592,7 @@ sendWebAppData bot_user_id:int53 button_text:string data:string = Ok;
//@description Informs TDLib that a Web App is being opened from attachment menu, a botMenuButton button, an internalLinkTypeAttachmentMenuBot link, or an inlineKeyboardButtonTypeWebApp button.
//-For each bot, a confirmation alert about data sent to the bot must be shown once
//@chat_id Identifier of the chat in which the Web App is opened
//@chat_id Identifier of the chat in which the Web App is opened. The Web App can't be opened in secret chats
//@bot_user_id Identifier of the bot, providing the Web App
//@url The URL from an inlineKeyboardButtonTypeWebApp button, a botMenuButton button, or an internalLinkTypeAttachmentMenuBot link, or an empty string otherwise
//@theme Preferred Web App theme; pass null to use the default theme

View File

@ -748,7 +748,8 @@ void AttachMenuManager::request_app_web_view(DialogId dialog_id, UserId bot_user
string &&start_parameter,
const td_api::object_ptr<td_api::themeParameters> &theme,
string &&platform, bool allow_write_access, Promise<string> &&promise) {
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read) ||
dialog_id.get_type() == DialogType::SecretChat) {
dialog_id = DialogId(bot_user_id);
}
TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(bot_user_id));

View File

@ -253,6 +253,9 @@ void CallbackQueriesManager::send_callback_query(FullMessageId full_message_id,
if (!full_message_id.get_message_id().is_server()) {
return promise.set_error(Status::Error(400, "Bad message identifier"));
}
if (dialog_id.get_type() == DialogType::SecretChat) {
return promise.set_error(Status::Error(400, "Secret chat messages can't have callback buttons"));
}
if (payload->get_id() == td_api::callbackQueryPayloadDataWithPassword::ID) {
auto password = static_cast<const td_api::callbackQueryPayloadDataWithPassword *>(payload.get())->password_;

View File

@ -8187,6 +8187,7 @@ void ContactsManager::report_channel_spam(ChannelId channel_id, const vector<Mes
}
auto sender_dialog_id = td_->messages_manager_->get_dialog_message_sender({DialogId(channel_id), message_id});
CHECK(sender_dialog_id.get_type() != DialogType::SecretChat);
if (sender_dialog_id.is_valid() && sender_dialog_id != DialogId(get_my_id()) &&
td_->messages_manager_->have_input_peer(sender_dialog_id, AccessRights::Know)) {
server_message_ids[sender_dialog_id].push_back(message_id);

View File

@ -266,7 +266,7 @@ void GameManager::get_game_high_scores(FullMessageId full_message_id, UserId use
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
auto message_id = full_message_id.get_message_id();
if (message_id.is_scheduled() || !message_id.is_server()) {
if (message_id.is_scheduled() || !message_id.is_server() || dialog_id.get_type() == DialogType::SecretChat) {
return promise.set_error(Status::Error(400, "Wrong message identifier specified"));
}