Fix send_update_new_message.
GitOrigin-RevId: 12d4f0c6aa9b84b91bb1438fb1ffecab48381471
This commit is contained in:
parent
0e48dd8a81
commit
3229ea3ce2
@ -18952,8 +18952,8 @@ void MessagesManager::send_update_new_message(Dialog *d, const Message *m, bool
|
||||
}
|
||||
bool have_settings = true;
|
||||
DialogId settings_dialog_id;
|
||||
Dialog *settings_dialog = nullptr;
|
||||
if (!disable_notification) {
|
||||
Dialog *settings_dialog;
|
||||
if (!m->contains_mention || !m->sender_user_id.is_valid()) {
|
||||
// use notification settings from the dialog
|
||||
settings_dialog_id = d->dialog_id;
|
||||
@ -18985,7 +18985,11 @@ void MessagesManager::send_update_new_message(Dialog *d, const Message *m, bool
|
||||
auto promise = PromiseCreator::lambda([actor_id = actor_id(this), dialog_id = d->dialog_id](Result<Unit> result) {
|
||||
send_closure(actor_id, &MessagesManager::flush_pending_update_new_messages, dialog_id);
|
||||
});
|
||||
send_get_dialog_notification_settings_query(settings_dialog_id, std::move(promise));
|
||||
if (settings_dialog != nullptr) {
|
||||
send_get_dialog_notification_settings_query(settings_dialog_id, std::move(promise));
|
||||
} else {
|
||||
send_get_dialog_query(settings_dialog_id, std::move(promise));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -19944,9 +19948,13 @@ DialogId MessagesManager::search_public_dialog(const string &username_to_search,
|
||||
}
|
||||
|
||||
void MessagesManager::send_get_dialog_notification_settings_query(DialogId dialog_id, Promise<Unit> &&promise) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return;
|
||||
if (td_->auth_manager_->is_bot() || dialog_id.get_type() != DialogType::SecretChat) {
|
||||
return promise.set_error(Status::Error(500, "Wrong getDialogNotificationSettings query"));
|
||||
}
|
||||
if (!have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
auto &promises = get_dialog_notification_settings_queries_[dialog_id];
|
||||
promises.push_back(std::move(promise));
|
||||
if (promises.size() != 1) {
|
||||
@ -19954,10 +19962,6 @@ void MessagesManager::send_get_dialog_notification_settings_query(DialogId dialo
|
||||
return;
|
||||
}
|
||||
|
||||
if (!have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
td_->create_handler<GetDialogNotifySettingsQuery>()->send(dialog_id);
|
||||
}
|
||||
|
||||
@ -19978,9 +19982,13 @@ void MessagesManager::on_get_dialog_notification_settings_query_finished(DialogI
|
||||
}
|
||||
|
||||
void MessagesManager::send_get_dialog_query(DialogId dialog_id, Promise<Unit> &&promise) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return;
|
||||
if (td_->auth_manager_->is_bot() || dialog_id.get_type() != DialogType::SecretChat) {
|
||||
return promise.set_error(Status::Error(500, "Wrong getDialog query"));
|
||||
}
|
||||
if (!have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
auto &promises = get_dialog_queries_[dialog_id];
|
||||
promises.push_back(std::move(promise));
|
||||
if (promises.size() != 1) {
|
||||
|
@ -41,17 +41,17 @@ TEST(Mtproto, config) {
|
||||
auto guard = sched.get_current_guard();
|
||||
|
||||
auto run = [&](auto &func, bool is_test) {
|
||||
cnt++;
|
||||
auto promise = PromiseCreator::lambda([&](Result<SimpleConfig> r_simple_config) {
|
||||
auto promise = PromiseCreator::lambda([&, num = cnt](Result<SimpleConfig> r_simple_config) {
|
||||
if (r_simple_config.is_ok()) {
|
||||
LOG(ERROR) << to_string(r_simple_config.ok());
|
||||
LOG(ERROR) << num << " " << to_string(r_simple_config.ok());
|
||||
} else {
|
||||
LOG(ERROR) << r_simple_config.error();
|
||||
LOG(ERROR) << num << " " << r_simple_config.error();
|
||||
}
|
||||
if (--cnt == 0) {
|
||||
Scheduler::instance()->finish();
|
||||
}
|
||||
});
|
||||
cnt++;
|
||||
func(std::move(promise), is_test, -1).release();
|
||||
};
|
||||
|
||||
@ -178,13 +178,13 @@ class HandshakeTestActor : public Actor {
|
||||
}
|
||||
|
||||
private:
|
||||
int32 dc_id_ = 0;
|
||||
Status *result_;
|
||||
bool wait_for_raw_connection_ = false;
|
||||
std::unique_ptr<RawConnection> raw_connection_;
|
||||
bool wait_for_handshake_ = false;
|
||||
std::unique_ptr<AuthKeyHandshake> handshake_;
|
||||
Status status_;
|
||||
int32 dc_id_ = 0;
|
||||
bool wait_for_result_ = false;
|
||||
|
||||
void tear_down() override {
|
||||
|
Loading…
Reference in New Issue
Block a user