diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 9570eb9a9..cc0e9bf60 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -5950,46 +5950,6 @@ void MessagesManager::on_update_delete_scheduled_messages(DialogId dialog_id, send_update_chat_has_scheduled_messages(d, true); } -void MessagesManager::on_update_include_sponsored_dialog_to_unread_count() { - if (td_->auth_manager_->is_bot()) { - // just in case - return; - } - - bool include_sponsored_dialog = G()->shared_config().get_option_boolean("include_sponsored_chat_to_unread_count"); - if (include_sponsored_dialog_to_unread_count_ == include_sponsored_dialog) { - return; - } - if (sponsored_dialog_id_.is_valid()) { - // preload sponsored dialog - get_dialog_force(sponsored_dialog_id_); - } - - include_sponsored_dialog_to_unread_count_ = include_sponsored_dialog; - - if (!sponsored_dialog_id_.is_valid()) { - // nothing has changed - return; - } - if (!G()->parameters().use_message_db) { - // there is no support for unread count updates without message database - return; - } - - auto folder_id = FolderId::main(); - auto &list = get_dialog_list(folder_id); - const Dialog *d = get_dialog(sponsored_dialog_id_); - CHECK(d != nullptr); - auto unread_count = d->server_unread_count + d->local_unread_count; - if (unread_count != 0 && list.is_message_unread_count_inited_) { - send_update_unread_message_count(folder_id, d->dialog_id, true, - "on_update_include_sponsored_dialog_to_unread_count"); - } - if ((unread_count != 0 || d->is_marked_as_unread) && list.is_dialog_unread_count_inited_) { - send_update_unread_chat_count(folder_id, d->dialog_id, true, "on_update_include_sponsored_dialog_to_unread_count"); - } -} - bool MessagesManager::need_cancel_user_dialog_action(int32 action_id, MessageContentType message_content_type) { if (message_content_type == MessageContentType::None) { return true; @@ -10333,9 +10293,6 @@ void MessagesManager::init() { start_time_ = Time::now(); - include_sponsored_dialog_to_unread_count_ = - G()->shared_config().get_option_boolean("include_sponsored_chat_to_unread_count"); - if (G()->parameters().use_message_db) { // erase old keys G()->td_db()->get_binlog_pmc()->erase("last_server_dialog_date"); @@ -30612,20 +30569,6 @@ td_api::object_ptr MessagesManager::get_update CHECK(list.is_message_unread_count_inited_); int32 unread_count = list.unread_message_total_count_; int32 unread_unmuted_count = list.unread_message_total_count_ - list.unread_message_muted_count_; - - if (include_sponsored_dialog_to_unread_count_ && sponsored_dialog_id_.is_valid() && - list.folder_id == FolderId::main()) { - const Dialog *d = get_dialog(sponsored_dialog_id_); - CHECK(d != nullptr); - auto sponsored_unread_count = d->server_unread_count + d->local_unread_count; - if (is_dialog_sponsored(d) && sponsored_unread_count != 0) { - unread_count += sponsored_unread_count; - if (!is_dialog_muted(d)) { - unread_unmuted_count += sponsored_unread_count; - } - } - } - CHECK(unread_count >= 0); CHECK(unread_unmuted_count >= 0); return td_api::make_object(get_chat_list_object(list.folder_id), unread_count, @@ -30643,26 +30586,6 @@ td_api::object_ptr MessagesManager::get_update_un CHECK(unread_unmuted_count >= 0); CHECK(unread_marked_count >= 0); CHECK(unread_unmuted_marked_count >= 0); - - if (include_sponsored_dialog_to_unread_count_ && sponsored_dialog_id_.is_valid() && - list.folder_id == FolderId::main()) { - const Dialog *d = get_dialog(sponsored_dialog_id_); - CHECK(d != nullptr); - auto sponsored_unread_count = d->server_unread_count + d->local_unread_count; - if (is_dialog_sponsored(d) && (sponsored_unread_count != 0 || d->is_marked_as_unread)) { - unread_count++; - if (sponsored_unread_count == 0 && d->is_marked_as_unread) { - unread_marked_count++; - } - if (!is_dialog_muted(d)) { - unread_unmuted_count++; - if (sponsored_unread_count == 0 && d->is_marked_as_unread) { - unread_unmuted_marked_count++; - } - } - } - } - return td_api::make_object( get_chat_list_object(list.folder_id), get_dialog_total_count(list), unread_count, unread_unmuted_count, unread_marked_count, unread_unmuted_marked_count); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 257c8c98b..29fa208fe 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -331,8 +331,6 @@ class MessagesManager : public Actor { void on_update_delete_scheduled_messages(DialogId dialog_id, vector &&server_message_ids); - void on_update_include_sponsored_dialog_to_unread_count(); - void on_user_dialog_action(DialogId dialog_id, UserId user_id, tl_object_ptr &&action, int32 date, MessageContentType message_content_type = MessageContentType::None); @@ -2672,8 +2670,6 @@ class MessagesManager : public Actor { uint64 current_message_edit_generation_ = 0; - bool include_sponsored_dialog_to_unread_count_ = false; - std::unordered_set postponed_unread_message_count_updates_; std::unordered_set postponed_unread_chat_count_updates_; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 9d646f9f6..0b648b1d3 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -3490,8 +3490,6 @@ void Td::on_config_option_updated(const string &name) { return stickers_manager_->on_update_recent_stickers_limit(G()->shared_config().get_option_integer(name)); } else if (name == "favorite_stickers_limit") { stickers_manager_->on_update_favorite_stickers_limit(G()->shared_config().get_option_integer(name)); - } else if (name == "include_sponsored_chat_to_unread_count") { - messages_manager_->on_update_include_sponsored_dialog_to_unread_count(); } else if (name == "my_id") { G()->set_my_id(G()->shared_config().get_option_integer(name)); } else if (name == "session_count") { @@ -6806,12 +6804,6 @@ void Td::on_request(uint64 id, td_api::setOption &request) { if (set_boolean_option("is_emulator")) { return; } - // this option currently can't be set, because unread count doesn't work for channels, - // in which user have never been a member - if (false && !is_bot && set_boolean_option("include_sponsored_chat_to_unread_count")) { - return; - } - if (!is_bot && request.name_ == "ignore_sensitive_content_restrictions") { if (!G()->shared_config().get_option_boolean("can_ignore_sensitive_content_restrictions")) { return send_error_raw(id, 3, "Option \"ignore_sensitive_content_restrictions\" can't be changed by the user");