Better warning silencing in force_create_dialog.

GitOrigin-RevId: 2f10cbe2091f2d2d8e15de8e813c5997954f9900
This commit is contained in:
levlam 2019-12-25 22:57:12 +03:00
parent 4e77501d9e
commit 7e1fa1fcb9
5 changed files with 17 additions and 18 deletions

View File

@ -182,7 +182,7 @@ void CallbackQueriesManager::on_new_query(int32 flags, int64 callback_query_id,
return;
}
td_->messages_manager_->force_create_dialog(dialog_id, "on_new_callback_query");
td_->messages_manager_->force_create_dialog(dialog_id, "on_new_callback_query", true);
send_closure(
G()->td(), &Td::send_update,
make_tl_object<td_api::updateNewCallbackQuery>(

View File

@ -3721,7 +3721,7 @@ bool ContactsManager::have_input_peer_channel(const Channel *c, ChannelId channe
if (!c->username.empty() || c->has_location) {
return true;
}
if (!from_linked && c->has_linked_channel) {
if (!from_linked) {
auto linked_channel_id = get_linked_channel_id(channel_id);
if (linked_channel_id.is_valid() &&
have_input_peer_channel(get_channel(linked_channel_id), linked_channel_id, access_rights, true)) {
@ -8089,7 +8089,7 @@ void ContactsManager::update_channel(Channel *c, ChannelId channel_id, bool from
} else if (!from_database && c->was_member != is_member) {
DialogId dialog_id(channel_id);
send_closure_later(G()->messages_manager(), &MessagesManager::force_create_dialog, dialog_id, "update channel",
true);
true, true);
}
c->had_read_access = have_read_access;
c->was_member = is_member;
@ -8117,7 +8117,7 @@ void ContactsManager::update_secret_chat(SecretChat *c, SecretChatId secret_chat
DialogId dialog_id(secret_chat_id);
send_closure_later(G()->messages_manager(), &MessagesManager::force_create_dialog, dialog_id, "update secret chat",
true);
true, true);
if (c->is_state_changed) {
send_closure_later(G()->messages_manager(), &MessagesManager::on_update_secret_chat_state, secret_chat_id,
c->state);
@ -8229,7 +8229,8 @@ void ContactsManager::update_channel_full(ChannelFull *channel_full, ChannelId c
channel_full->is_changed = false;
if (channel_full->need_send_update) {
if (channel_full->linked_channel_id.is_valid()) {
td_->messages_manager_->force_create_dialog(DialogId(channel_full->linked_channel_id), "update_channel_full");
td_->messages_manager_->force_create_dialog(DialogId(channel_full->linked_channel_id), "update_channel_full",
true);
}
send_closure(

View File

@ -20265,14 +20265,14 @@ unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_for
} else {
LOG_IF(ERROR, td_->contacts_manager_->have_min_channel(channel_id)) << "Receive forward from min channel";
dialog_id = DialogId(channel_id);
force_create_dialog(dialog_id, "message forward info");
force_create_dialog(dialog_id, "message forward info", true);
if (sender_user_id.is_valid()) {
LOG(ERROR) << "Receive valid sender user id in message forward header: " << oneline(to_string(forward_header));
sender_user_id = UserId();
}
}
if (from_dialog_id.is_valid()) {
force_create_dialog(from_dialog_id, "message forward from info");
force_create_dialog(from_dialog_id, "message forward from info", true);
}
return td::make_unique<MessageForwardInfo>(sender_user_id, forward_header->date_, dialog_id, message_id,
@ -23770,7 +23770,7 @@ DialogId MessagesManager::search_public_dialog(const string &username_to_search,
if (dialog_id.is_valid()) {
if (have_input_peer(dialog_id, AccessRights::Read)) {
if (td_->auth_manager_->is_bot()) {
force_create_dialog(dialog_id, "search public dialog");
force_create_dialog(dialog_id, "search public dialog", true);
} else {
const Dialog *d = get_dialog_force(dialog_id);
if (!is_dialog_inited(d)) {
@ -23784,7 +23784,7 @@ DialogId MessagesManager::search_public_dialog(const string &username_to_search,
} else {
// bot username maybe known despite there is no access_hash
if (force || dialog_id.get_type() != DialogType::User) {
force_create_dialog(dialog_id, "search public dialog");
force_create_dialog(dialog_id, "search public dialog", true);
promise.set_value(Unit());
return dialog_id;
}
@ -27259,7 +27259,8 @@ MessageId MessagesManager::get_message_id_by_random_id(Dialog *d, int64 random_i
return it->second;
}
void MessagesManager::force_create_dialog(DialogId dialog_id, const char *source, bool force_update_dialog_pos) {
void MessagesManager::force_create_dialog(DialogId dialog_id, const char *source, bool expect_no_access,
bool force_update_dialog_pos) {
LOG_CHECK(dialog_id.is_valid()) << source;
Dialog *d = get_dialog_force(dialog_id);
if (d == nullptr) {
@ -27319,12 +27320,8 @@ void MessagesManager::force_create_dialog(DialogId dialog_id, const char *source
if (!have_input_peer(dialog_id, AccessRights::Read)) {
if (!have_dialog_info(dialog_id)) {
LOG(ERROR) << "Have no info about " << dialog_id << " received from " << source << ", but forced to create it";
} else {
LOG_IF(ERROR,
Slice(source) != Slice("message forward info") && Slice(source) != Slice("message forward from info") &&
Slice(source) != Slice("on_new_callback_query") && Slice(source) != Slice("search public dialog") &&
Slice(source) != Slice("create new secret chat") && !force_update_dialog_pos)
<< "Have no access to " << dialog_id << " received from " << source << ", but forced to create it";
} else if (!expect_no_access) {
LOG(ERROR) << "Have no access to " << dialog_id << " received from " << source << ", but forced to create it";
}
}
} else if (force_update_dialog_pos) {

View File

@ -747,7 +747,8 @@ class MessagesManager : public Actor {
void on_get_channel_difference(DialogId dialog_id, int32 request_pts, int32 request_limit,
tl_object_ptr<telegram_api::updates_ChannelDifference> &&difference_ptr);
void force_create_dialog(DialogId dialog_id, const char *source, bool force_update_dialog_pos = false);
void force_create_dialog(DialogId dialog_id, const char *source, bool expect_no_access = false,
bool force_update_dialog_pos = false);
void send_get_dialog_notification_settings_query(DialogId dialog_id, Promise<Unit> &&promise);

View File

@ -1830,7 +1830,7 @@ class CreateNewSecretChatRequest : public RequestActor<SecretChatId> {
secret_chat_id_, 0 /* no access_hash */, user_id_, SecretChatState::Unknown, true /* it is outbound chat */,
-1 /* unknown ttl */, 0 /* unknown creation date */, "" /* no key_hash */, 0);
DialogId dialog_id(secret_chat_id_);
td->messages_manager_->force_create_dialog(dialog_id, "create new secret chat");
td->messages_manager_->force_create_dialog(dialog_id, "create new secret chat", true);
send_result(td->messages_manager_->get_chat_object(dialog_id));
}