Use check_dialog_access_in_memory if appropriate.
This commit is contained in:
parent
c4e1a44a5c
commit
575acc5485
@ -380,9 +380,8 @@ void MessageImportManager::on_upload_imported_messages(FileId file_id,
|
||||
|
||||
being_uploaded_imported_messages_.erase(it);
|
||||
|
||||
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"));
|
||||
}
|
||||
TRY_STATUS_PROMISE(promise,
|
||||
td_->dialog_manager_->check_dialog_access_in_memory(dialog_id, false, AccessRights::Write));
|
||||
|
||||
FileView file_view = td_->file_manager_->get_file_view(file_id);
|
||||
CHECK(!file_view.is_encrypted());
|
||||
@ -432,9 +431,8 @@ 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, false, AccessRights::Write)) {
|
||||
return promise.set_error(Status::Error(400, "Have no write access to the chat"));
|
||||
}
|
||||
TRY_STATUS_PROMISE(promise,
|
||||
td_->dialog_manager_->check_dialog_access_in_memory(dialog_id, false, AccessRights::Write));
|
||||
|
||||
auto pending_message_import = make_unique<PendingMessageImport>();
|
||||
pending_message_import->dialog_id = dialog_id;
|
||||
@ -567,9 +565,8 @@ 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, false, AccessRights::Write)) {
|
||||
return promise.set_error(Status::Error(400, "Have no write access to the chat"));
|
||||
}
|
||||
TRY_STATUS_PROMISE(promise,
|
||||
td_->dialog_manager_->check_dialog_access_in_memory(dialog_id, false, AccessRights::Write));
|
||||
|
||||
td_->create_handler<StartImportHistoryQuery>(std::move(promise))->send(dialog_id, pending_message_import->import_id);
|
||||
}
|
||||
|
@ -1405,14 +1405,12 @@ FileSourceId NotificationSettingsManager::get_saved_ringtones_file_source_id() {
|
||||
void NotificationSettingsManager::send_get_dialog_notification_settings_query(DialogId dialog_id,
|
||||
MessageId top_thread_message_id,
|
||||
Promise<Unit> &&promise) {
|
||||
if (td_->auth_manager_->is_bot() || dialog_id.get_type() == DialogType::SecretChat) {
|
||||
LOG(WARNING) << "Can't get notification settings for " << dialog_id;
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
LOG(ERROR) << "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, 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"));
|
||||
}
|
||||
TRY_STATUS_PROMISE(promise,
|
||||
td_->dialog_manager_->check_dialog_access_in_memory(dialog_id, false, AccessRights::Read));
|
||||
|
||||
auto &promises = get_dialog_notification_settings_queries_[{dialog_id, top_thread_message_id}];
|
||||
promises.push_back(std::move(promise));
|
||||
|
Loading…
x
Reference in New Issue
Block a user