Remove unsupported include_sponsored_chat_to_unread_count option.
GitOrigin-RevId: dcedd9c37b8e5453590e092a3651456a4c62ad1c
This commit is contained in:
parent
65c6ac69eb
commit
5da08f8bb1
@ -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<td_api::updateUnreadMessageCount> 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<td_api::updateUnreadMessageCount>(get_chat_list_object(list.folder_id), unread_count,
|
||||
@ -30643,26 +30586,6 @@ td_api::object_ptr<td_api::updateUnreadChatCount> 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<td_api::updateUnreadChatCount>(
|
||||
get_chat_list_object(list.folder_id), get_dialog_total_count(list), unread_count, unread_unmuted_count,
|
||||
unread_marked_count, unread_unmuted_marked_count);
|
||||
|
@ -331,8 +331,6 @@ class MessagesManager : public Actor {
|
||||
|
||||
void on_update_delete_scheduled_messages(DialogId dialog_id, vector<ScheduledServerMessageId> &&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<td_api::ChatAction> &&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<FolderId, FolderIdHash> postponed_unread_message_count_updates_;
|
||||
std::unordered_set<FolderId, FolderIdHash> postponed_unread_chat_count_updates_;
|
||||
|
||||
|
@ -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");
|
||||
|
Reference in New Issue
Block a user