Add explicit allow_secret_chats to have_input_peer.
This commit is contained in:
parent
5d16b620aa
commit
c0ed8f09b0
@ -824,8 +824,7 @@ 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_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read) ||
|
||||
dialog_id.get_type() == DialogType::SecretChat) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
dialog_id = DialogId(bot_user_id);
|
||||
}
|
||||
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(bot_user_id));
|
||||
@ -861,7 +860,7 @@ void AttachMenuManager::request_web_view(DialogId dialog_id, UserId bot_user_id,
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Write)) {
|
||||
return promise.set_error(Status::Error(400, "Have no write access to the chat"));
|
||||
}
|
||||
|
||||
|
@ -768,7 +768,7 @@ Result<DialogId> BackgroundManager::get_background_dialog(DialogId dialog_id) {
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_background_dialog")) {
|
||||
return Status::Error(400, "Chat not found");
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, true, AccessRights::Write)) {
|
||||
return Status::Error(400, "Can't access the chat");
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ void BoostManager::get_dialog_boost_status(DialogId dialog_id,
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
@ -415,7 +415,7 @@ void BoostManager::boost_dialog(DialogId dialog_id, vector<int32> slot_ids,
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "boost_dialog")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
if (slot_ids.empty()) {
|
||||
@ -429,7 +429,7 @@ Result<std::pair<string, bool>> BoostManager::get_dialog_boost_link(DialogId dia
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_boost_link")) {
|
||||
return Status::Error(400, "Chat not found");
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return Status::Error(400, "Can't access the chat");
|
||||
}
|
||||
if (dialog_id.get_type() != DialogType::Channel) {
|
||||
@ -478,7 +478,7 @@ void BoostManager::get_dialog_boosts(DialogId dialog_id, bool only_gift_codes, c
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_dialog_boosts")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
if (limit <= 0) {
|
||||
@ -493,7 +493,7 @@ void BoostManager::get_user_dialog_boosts(DialogId dialog_id, UserId user_id,
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_user_dialog_boosts")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
if (!user_id.is_valid()) {
|
||||
|
@ -66,7 +66,7 @@ Result<BotCommandScope> BotCommandScope::get_bot_command_scope(Td *td,
|
||||
if (!td->dialog_manager_->have_dialog_force(dialog_id, "get_bot_command_scope")) {
|
||||
return Status::Error(400, "Chat not found");
|
||||
}
|
||||
if (!td->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return Status::Error(400, "Can't access the chat");
|
||||
}
|
||||
switch (dialog_id.get_type()) {
|
||||
@ -85,7 +85,7 @@ Result<BotCommandScope> BotCommandScope::get_bot_command_scope(Td *td,
|
||||
break;
|
||||
case DialogType::SecretChat:
|
||||
default:
|
||||
return Status::Error(400, "Can't access the chat");
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
return BotCommandScope(type, dialog_id, user_id);
|
||||
|
@ -238,7 +238,7 @@ void CallbackQueriesManager::send_callback_query(MessageFullId message_full_id,
|
||||
|
||||
auto dialog_id = message_full_id.get_dialog_id();
|
||||
td_->dialog_manager_->have_dialog_force(dialog_id, "send_callback_query");
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
@ -251,9 +251,6 @@ void CallbackQueriesManager::send_callback_query(MessageFullId message_full_id,
|
||||
if (!message_full_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_;
|
||||
@ -278,10 +275,10 @@ void CallbackQueriesManager::send_get_callback_answer_query(
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
|
||||
auto dialog_id = message_full_id.get_dialog_id();
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
if (!td_->messages_manager_->have_message_force(message_full_id, "send_callback_query")) {
|
||||
if (!td_->messages_manager_->have_message_force(message_full_id, "send_get_callback_answer_query")) {
|
||||
return promise.set_error(Status::Error(400, "Message not found"));
|
||||
}
|
||||
|
||||
|
@ -3549,7 +3549,7 @@ void ChatManager::report_channel_spam(ChannelId channel_id, const vector<Message
|
||||
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 != td_->dialog_manager_->get_my_dialog_id() &&
|
||||
td_->dialog_manager_->have_input_peer(sender_dialog_id, AccessRights::Know)) {
|
||||
td_->dialog_manager_->have_input_peer(sender_dialog_id, false, AccessRights::Know)) {
|
||||
server_message_ids[sender_dialog_id].push_back(message_id);
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ void DialogActionManager::send_dialog_action(DialogId dialog_id, MessageId top_t
|
||||
} else if (as_business) {
|
||||
input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Know);
|
||||
} else {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, true, AccessRights::Write)) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return promise.set_error(Status::Error(400, "Have no write access to the chat"));
|
||||
}
|
||||
|
@ -2150,7 +2150,7 @@ void DialogFilterManager::add_dialog_filter_by_invite_link(const string &invite_
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "add_dialog_filter_by_invite_link")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Know)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Know)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
}
|
||||
@ -2184,7 +2184,7 @@ void DialogFilterManager::add_dialog_filter_new_chats(DialogFilterId dialog_filt
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "add_dialog_filter_new_chats")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Know)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Know)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ tl_object_ptr<telegram_api::inputEncryptedChat> DialogManager::get_input_encrypt
|
||||
}
|
||||
}
|
||||
|
||||
bool DialogManager::have_input_peer(DialogId dialog_id, AccessRights access_rights) const {
|
||||
bool DialogManager::have_input_peer(DialogId dialog_id, bool allow_secret_chats, AccessRights access_rights) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User: {
|
||||
UserId user_id = dialog_id.get_user_id();
|
||||
@ -686,6 +686,9 @@ bool DialogManager::have_input_peer(DialogId dialog_id, AccessRights access_righ
|
||||
return td_->chat_manager_->have_input_peer_channel(channel_id, access_rights);
|
||||
}
|
||||
case DialogType::SecretChat: {
|
||||
if (!allow_secret_chats) {
|
||||
return false;
|
||||
}
|
||||
SecretChatId secret_chat_id = dialog_id.get_secret_chat_id();
|
||||
return td_->user_manager_->have_input_encrypted_peer(secret_chat_id, access_rights);
|
||||
}
|
||||
@ -1596,7 +1599,7 @@ void DialogManager::set_dialog_permissions(DialogId dialog_id,
|
||||
if (!have_dialog_force(dialog_id, "set_dialog_permissions")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
if (!have_input_peer(dialog_id, false, AccessRights::Write)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
@ -1628,7 +1631,6 @@ void DialogManager::set_dialog_permissions(DialogId dialog_id,
|
||||
break;
|
||||
}
|
||||
case DialogType::SecretChat:
|
||||
return promise.set_error(Status::Error(400, "Can't change secret chat permissions"));
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1675,13 +1677,12 @@ void DialogManager::toggle_dialog_has_protected_content(DialogId dialog_id, bool
|
||||
if (!have_dialog_force(dialog_id, "toggle_dialog_has_protected_content")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
case DialogType::SecretChat:
|
||||
return promise.set_error(Status::Error(400, "Can't restrict saving content in the chat"));
|
||||
case DialogType::Chat: {
|
||||
auto chat_id = dialog_id.get_chat_id();
|
||||
@ -1698,6 +1699,7 @@ void DialogManager::toggle_dialog_has_protected_content(DialogId dialog_id, bool
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DialogType::SecretChat:
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1774,7 +1776,7 @@ void DialogManager::report_dialog(DialogId dialog_id, const vector<MessageId> &m
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
|
||||
if (!have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!have_input_peer(dialog_id, true, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
@ -1818,7 +1820,7 @@ void DialogManager::report_dialog_photo(DialogId dialog_id, FileId file_id, Repo
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
|
||||
if (!have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
@ -1866,7 +1868,7 @@ Status DialogManager::can_pin_messages(DialogId dialog_id) const {
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
if (!have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
if (!have_input_peer(dialog_id, false, AccessRights::Write)) {
|
||||
return Status::Error(400, "Not enough rights");
|
||||
}
|
||||
|
||||
@ -2206,7 +2208,7 @@ DialogId DialogManager::search_public_dialog(const string &username_to_search, b
|
||||
return DialogId();
|
||||
}
|
||||
|
||||
if (have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
if (!force && reload_voice_chat_on_search_usernames_.count(username)) {
|
||||
reload_voice_chat_on_search_usernames_.erase(username);
|
||||
if (dialog_id.get_type() == DialogType::Channel) {
|
||||
@ -2251,8 +2253,7 @@ void DialogManager::drop_username(const string &username) {
|
||||
auto resolved_username = resolved_usernames_.get(cleaned_username);
|
||||
if (resolved_username.dialog_id.is_valid()) {
|
||||
auto dialog_id = resolved_username.dialog_id;
|
||||
if (have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
CHECK(dialog_id.get_type() != DialogType::SecretChat);
|
||||
if (have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
reload_dialog_info_full(dialog_id, "drop_username");
|
||||
}
|
||||
|
||||
@ -2306,7 +2307,7 @@ void DialogManager::dismiss_dialog_suggested_action(SuggestedAction action, Prom
|
||||
if (!td_->messages_manager_->have_dialog(dialog_id)) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class DialogManager final : public Actor {
|
||||
tl_object_ptr<telegram_api::inputEncryptedChat> get_input_encrypted_chat(DialogId dialog_id,
|
||||
AccessRights access_rights) const;
|
||||
|
||||
bool have_input_peer(DialogId dialog_id, AccessRights access_rights) const;
|
||||
bool have_input_peer(DialogId dialog_id, bool allow_secret_chats, AccessRights access_rights) const;
|
||||
|
||||
bool have_dialog_force(DialogId dialog_id, const char *source) const;
|
||||
|
||||
|
@ -208,7 +208,7 @@ void GameManager::set_game_score(MessageFullId message_full_id, bool edit_messag
|
||||
}
|
||||
|
||||
auto dialog_id = message_full_id.get_dialog_id();
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Edit)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Edit)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
@ -258,11 +258,11 @@ void GameManager::get_game_high_scores(MessageFullId message_full_id, UserId use
|
||||
}
|
||||
|
||||
auto dialog_id = message_full_id.get_dialog_id();
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
auto message_id = message_full_id.get_message_id();
|
||||
if (message_id.is_scheduled() || !message_id.is_server() || dialog_id.get_type() == DialogType::SecretChat) {
|
||||
if (message_id.is_scheduled() || !message_id.is_server()) {
|
||||
return promise.set_error(Status::Error(400, "Wrong message identifier specified"));
|
||||
}
|
||||
|
||||
|
@ -1229,7 +1229,7 @@ Status GroupCallManager::can_join_group_calls(DialogId dialog_id) const {
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_group_call_join_as")) {
|
||||
return Status::Error(400, "Chat not found");
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return Status::Error(400, "Can't access chat");
|
||||
}
|
||||
switch (dialog_id.get_type()) {
|
||||
@ -1237,8 +1237,8 @@ Status GroupCallManager::can_join_group_calls(DialogId dialog_id) const {
|
||||
case DialogType::Channel:
|
||||
break;
|
||||
case DialogType::User:
|
||||
case DialogType::SecretChat:
|
||||
return Status::Error(400, "Chat can't have a voice chat");
|
||||
case DialogType::SecretChat:
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1323,7 +1323,7 @@ void GroupCallManager::set_group_call_default_join_as(DialogId dialog_id, Dialog
|
||||
default:
|
||||
return promise.set_error(Status::Error(400, "Invalid default participant identifier specified"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(as_dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(as_dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access specified default participant chat"));
|
||||
}
|
||||
|
||||
@ -1339,7 +1339,7 @@ void GroupCallManager::create_voice_chat(DialogId dialog_id, string title, int32
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "create_voice_chat")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access chat"));
|
||||
}
|
||||
|
||||
@ -1368,7 +1368,7 @@ void GroupCallManager::get_voice_chat_rtmp_stream_url(DialogId dialog_id, bool r
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_voice_chat_rtmp_stream_url")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access chat"));
|
||||
}
|
||||
|
||||
@ -2651,12 +2651,9 @@ void GroupCallManager::join_group_call(GroupCallId group_call_id, DialogId as_di
|
||||
return promise.set_error(Status::Error(400, "Join as chat not found"));
|
||||
}
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(as_dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(as_dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the join as participant"));
|
||||
}
|
||||
if (dialog_type == DialogType::SecretChat) {
|
||||
return promise.set_error(Status::Error(400, "Can't join voice chat as a secret chat"));
|
||||
}
|
||||
}
|
||||
|
||||
if (group_call->is_being_left) {
|
||||
@ -4126,7 +4123,7 @@ void GroupCallManager::on_group_call_left_impl(GroupCall *group_call, bool need_
|
||||
group_call->need_rejoin = need_rejoin && !group_call->is_being_left;
|
||||
if (group_call->need_rejoin && group_call->dialog_id.is_valid()) {
|
||||
auto dialog_id = group_call->dialog_id;
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read) ||
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read) ||
|
||||
(dialog_id.get_type() == DialogType::Chat &&
|
||||
!td_->chat_manager_->get_chat_status(dialog_id.get_chat_id()).is_member())) {
|
||||
group_call->need_rejoin = false;
|
||||
|
@ -290,7 +290,7 @@ Status MessageImportManager::can_import_messages(DialogId dialog_id) {
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "can_import_messages")) {
|
||||
return Status::Error(400, "Chat not found");
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Write)) {
|
||||
return Status::Error(400, "Have no write access to the chat");
|
||||
}
|
||||
|
||||
@ -311,7 +311,6 @@ Status MessageImportManager::can_import_messages(DialogId dialog_id) {
|
||||
}
|
||||
break;
|
||||
case DialogType::SecretChat:
|
||||
return Status::Error(400, "Can't import messages to secret chats");
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -386,7 +385,7 @@ void MessageImportManager::on_upload_imported_messages(FileId file_id,
|
||||
|
||||
being_uploaded_imported_messages_.erase(it);
|
||||
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Write)) {
|
||||
return promise.set_error(Status::Error(400, "Have no write access to the chat"));
|
||||
}
|
||||
|
||||
@ -438,7 +437,7 @@ void MessageImportManager::on_upload_imported_messages_error(FileId file_id, Sta
|
||||
void MessageImportManager::start_import_messages(DialogId dialog_id, int64 import_id,
|
||||
vector<FileId> &&attached_file_ids, Promise<Unit> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Write)) {
|
||||
return promise.set_error(Status::Error(400, "Have no write access to the chat"));
|
||||
}
|
||||
|
||||
@ -573,7 +572,7 @@ void MessageImportManager::on_imported_message_attachments_uploaded(int64 random
|
||||
auto promise = std::move(pending_message_import->promise);
|
||||
auto dialog_id = pending_message_import->dialog_id;
|
||||
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Write)) {
|
||||
return promise.set_error(Status::Error(400, "Have no write access to the chat"));
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ MessageInputReplyTo::MessageInputReplyTo(Td *td,
|
||||
DialogId dialog_id;
|
||||
if (reply_to->reply_to_peer_id_ != nullptr) {
|
||||
dialog_id = InputDialogId(reply_to->reply_to_peer_id_).get_dialog_id();
|
||||
if (!dialog_id.is_valid() || !td->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!dialog_id.is_valid() || !td->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return;
|
||||
}
|
||||
td->dialog_manager_->force_create_dialog(dialog_id, "inputReplyToMessage");
|
||||
|
@ -873,8 +873,7 @@ StringBuilder &operator<<(StringBuilder &string_builder, const unique_ptr<Messag
|
||||
}
|
||||
|
||||
void reload_message_reactions(Td *td, DialogId dialog_id, vector<MessageId> &&message_ids) {
|
||||
if (!td->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read) ||
|
||||
dialog_id.get_type() == DialogType::SecretChat || message_ids.empty()) {
|
||||
if (!td->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read) || message_ids.empty()) {
|
||||
create_actor<SleepActor>(
|
||||
"RetryReloadMessageReactionsActor", 0.2,
|
||||
PromiseCreator::lambda([actor_id = G()->messages_manager(), dialog_id](Result<Unit> result) mutable {
|
||||
@ -941,12 +940,9 @@ void report_message_reactions(Td *td, MessageFullId message_full_id, DialogId ch
|
||||
if (!td->dialog_manager_->have_dialog_force(dialog_id, "send_callback_query")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
if (dialog_id.get_type() == DialogType::SecretChat) {
|
||||
return promise.set_error(Status::Error(400, "Reactions can't be reported in the chat"));
|
||||
}
|
||||
|
||||
if (!td->messages_manager_->have_message_force(message_full_id, "report_user_reactions")) {
|
||||
return promise.set_error(Status::Error(400, "Message not found"));
|
||||
@ -959,7 +955,7 @@ void report_message_reactions(Td *td, MessageFullId message_full_id, DialogId ch
|
||||
return promise.set_error(Status::Error(400, "Message reactions can't be reported"));
|
||||
}
|
||||
|
||||
if (!td->dialog_manager_->have_input_peer(chooser_dialog_id, AccessRights::Know)) {
|
||||
if (!td->dialog_manager_->have_input_peer(chooser_dialog_id, false, AccessRights::Know)) {
|
||||
return promise.set_error(Status::Error(400, "Reaction sender not found"));
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1409,7 +1409,7 @@ void NotificationSettingsManager::send_get_dialog_notification_settings_query(Di
|
||||
LOG(WARNING) << "Can't get notification settings for " << dialog_id;
|
||||
return promise.set_error(Status::Error(500, "Wrong getDialogNotificationSettings query"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
LOG(WARNING) << "Have no access to " << dialog_id << " to get notification settings";
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
@ -1411,7 +1411,7 @@ Result<vector<QuickReplyManager::QuickReplyMessageContent>> QuickReplyManager::g
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_quick_reply_message_contents")) {
|
||||
return Status::Error(400, "Chat not found");
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Write)) {
|
||||
return Status::Error(400, "Have no write access to the chat");
|
||||
}
|
||||
if (dialog_id.get_type() != DialogType::User || td_->user_manager_->is_user_bot(dialog_id.get_user_id())) {
|
||||
|
@ -144,7 +144,7 @@ void RecentDialogList::on_load_dialogs(vector<string> &&found_dialogs) {
|
||||
}
|
||||
if (dialog_id.is_valid() && td::contains(removed_dialog_ids_, dialog_id) == 0 &&
|
||||
td_->dialog_manager_->have_dialog_info(dialog_id) &&
|
||||
td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
td_->dialog_manager_->have_input_peer(dialog_id, true, AccessRights::Read)) {
|
||||
td_->dialog_manager_->force_create_dialog(dialog_id, "recent dialog");
|
||||
do_add_dialog(dialog_id);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ bool SavedMessagesTopicId::have_input_peer(Td *td) const {
|
||||
!td->dialog_manager_->have_dialog_info_force(dialog_id_, "SavedMessagesTopicId::have_input_peer")) {
|
||||
return false;
|
||||
}
|
||||
return td->dialog_manager_->have_input_peer(dialog_id_, AccessRights::Know);
|
||||
return td->dialog_manager_->have_input_peer(dialog_id_, false, AccessRights::Know);
|
||||
}
|
||||
|
||||
Status SavedMessagesTopicId::is_valid_status(Td *td) const {
|
||||
@ -75,7 +75,7 @@ Status SavedMessagesTopicId::is_valid_status(Td *td) const {
|
||||
return Status::Error(400, "Invalid Saved Messages topic specified");
|
||||
}
|
||||
if (!have_input_peer(td)) {
|
||||
return Status::Error(400, "Invalid Saved Messages topic specified");
|
||||
return Status::Error(400, "Unknown Saved Messages topic specified");
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
@ -86,7 +86,7 @@ Status SavedMessagesTopicId::is_valid_in(Td *td, DialogId dialog_id) const {
|
||||
return Status::Error(400, "Can't use Saved Messages topic in the chat");
|
||||
}
|
||||
if (!have_input_peer(td)) {
|
||||
return Status::Error(400, "Invalid Saved Messages topic specified");
|
||||
return Status::Error(400, "Unknown Saved Messages topic specified");
|
||||
}
|
||||
}
|
||||
return Status::OK();
|
||||
|
@ -6922,7 +6922,7 @@ void StickersManager::schedule_update_animated_emoji_clicked(const StickerSet *s
|
||||
return;
|
||||
}
|
||||
auto dialog_id = message_full_id.get_dialog_id();
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Write)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -6971,7 +6971,7 @@ void StickersManager::send_update_animated_emoji_clicked(MessageFullId message_f
|
||||
return;
|
||||
}
|
||||
auto dialog_id = message_full_id.get_dialog_id();
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Write)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -151,9 +151,7 @@ class ToggleStoriesHiddenQuery final : public Td::ResultHandler {
|
||||
dialog_id_ = dialog_id;
|
||||
are_hidden_ = are_hidden;
|
||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
|
||||
if (input_peer == nullptr) {
|
||||
return on_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
CHECK(input_peer != nullptr);
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::stories_togglePeerStoriesHidden(std::move(input_peer), are_hidden), {{dialog_id_}}));
|
||||
}
|
||||
@ -2304,7 +2302,7 @@ void StoryManager::toggle_dialog_stories_hidden(DialogId dialog_id, StoryListId
|
||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "toggle_dialog_stories_hidden")) {
|
||||
return promise.set_error(Status::Error(400, "Story sender not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the story sender"));
|
||||
}
|
||||
if (story_list_id == get_dialog_story_list_id(dialog_id)) {
|
||||
@ -2327,7 +2325,7 @@ void StoryManager::get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId f
|
||||
if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "get_dialog_pinned_stories")) {
|
||||
return promise.set_error(Status::Error(400, "Story sender not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the story sender"));
|
||||
}
|
||||
|
||||
@ -2401,7 +2399,7 @@ void StoryManager::get_dialog_expiring_stories(DialogId owner_dialog_id,
|
||||
if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "get_dialog_expiring_stories")) {
|
||||
return promise.set_error(Status::Error(400, "Story sender not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the story sender"));
|
||||
}
|
||||
|
||||
@ -2431,7 +2429,7 @@ void StoryManager::get_dialog_expiring_stories(DialogId owner_dialog_id,
|
||||
}
|
||||
|
||||
void StoryManager::reload_dialog_expiring_stories(DialogId dialog_id) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(dialog_id, false, AccessRights::Read)) {
|
||||
return;
|
||||
}
|
||||
td_->dialog_manager_->force_create_dialog(dialog_id, "reload_dialog_expiring_stories");
|
||||
@ -2521,7 +2519,7 @@ void StoryManager::open_story(DialogId owner_dialog_id, StoryId story_id, Promis
|
||||
if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "open_story")) {
|
||||
return promise.set_error(Status::Error(400, "Story sender not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the story sender"));
|
||||
}
|
||||
if (!story_id.is_valid()) {
|
||||
@ -2584,7 +2582,7 @@ void StoryManager::close_story(DialogId owner_dialog_id, StoryId story_id, Promi
|
||||
if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "close_story")) {
|
||||
return promise.set_error(Status::Error(400, "Story sender not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the story sender"));
|
||||
}
|
||||
if (!story_id.is_valid()) {
|
||||
@ -2696,7 +2694,7 @@ void StoryManager::set_story_reaction(StoryFullId story_full_id, ReactionType re
|
||||
if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "set_story_reaction")) {
|
||||
return promise.set_error(Status::Error(400, "Story sender not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the story sender"));
|
||||
}
|
||||
if (!story_full_id.get_story_id().is_valid()) {
|
||||
@ -4609,7 +4607,7 @@ void StoryManager::get_story(DialogId owner_dialog_id, StoryId story_id, bool on
|
||||
if (!td_->dialog_manager_->have_dialog_force(owner_dialog_id, "get_story")) {
|
||||
return promise.set_error(Status::Error(400, "Story sender not found"));
|
||||
}
|
||||
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
|
||||
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, false, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the story sender"));
|
||||
}
|
||||
if (!story_id.is_valid()) {
|
||||
|
Loading…
Reference in New Issue
Block a user