Move online member count to DialogOnlineMemberManager.

This commit is contained in:
levlam 2024-01-04 18:30:12 +03:00
parent 211071970e
commit 3003679192
6 changed files with 258 additions and 220 deletions

View File

@ -17,6 +17,7 @@
#include "td/telegram/DialogInviteLink.h"
#include "td/telegram/DialogLocation.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/DialogOnlineMemberManager.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/FileReferenceManager.h"
@ -13969,7 +13970,8 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
}
if (participant_count >= 190 || !can_get_participants || has_hidden_participants) {
td_->messages_manager_->on_update_dialog_online_member_count(DialogId(channel_id), channel->online_count_, true);
td_->dialog_online_member_manager_->on_update_dialog_online_member_count(DialogId(channel_id),
channel->online_count_, true);
}
vector<UserId> bot_user_ids;
@ -15138,7 +15140,7 @@ void ContactsManager::update_user_online_member_count(User *u) {
for (const auto &it : u->online_member_dialogs) {
auto dialog_id = it.first;
auto time = it.second;
if (time < now - MessagesManager::ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME) {
if (time < now - DialogOnlineMemberManager::ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME) {
expired_dialog_ids.push_back(dialog_id);
continue;
}
@ -15212,7 +15214,8 @@ void ContactsManager::update_dialog_online_member_count(const vector<DialogParti
}
}
}
td_->messages_manager_->on_update_dialog_online_member_count(dialog_id, online_member_count, is_from_server);
td_->dialog_online_member_manager_->on_update_dialog_online_member_count(dialog_id, online_member_count,
is_from_server);
}
void ContactsManager::on_get_chat_participants(tl_object_ptr<telegram_api::ChatParticipants> &&participants_ptr,

View File

@ -6,14 +6,224 @@
//
#include "td/telegram/DialogOnlineMemberManager.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h"
#include "td/utils/buffer.h"
#include "td/utils/logging.h"
#include "td/utils/Status.h"
#include "td/utils/Time.h"
namespace td {
class GetOnlinesQuery final : public Td::ResultHandler {
DialogId dialog_id_;
public:
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
CHECK(dialog_id.get_type() == DialogType::Channel);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
send_query(G()->net_query_creator().create(telegram_api::messages_getOnlines(std::move(input_peer))));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getOnlines>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
td_->dialog_online_member_manager_->on_update_dialog_online_member_count(dialog_id_, result->onlines_, true);
}
void on_error(Status status) final {
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetOnlinesQuery");
td_->dialog_online_member_manager_->on_update_dialog_online_member_count(dialog_id_, 0, true);
}
};
DialogOnlineMemberManager::DialogOnlineMemberManager(Td *td, ActorShared<> parent)
: td_(td), parent_(std::move(parent)) {
update_dialog_online_member_count_timeout_.set_callback(on_update_dialog_online_member_count_timeout_callback);
update_dialog_online_member_count_timeout_.set_callback_data(static_cast<void *>(this));
}
void DialogOnlineMemberManager::tear_down() {
parent_.reset();
}
void DialogOnlineMemberManager::on_update_dialog_online_member_count_timeout_callback(
void *dialog_online_member_manager_ptr, int64 dialog_id_int) {
if (G()->close_flag()) {
return;
}
auto dialog_online_member_manager = static_cast<DialogOnlineMemberManager *>(dialog_online_member_manager_ptr);
send_closure_later(dialog_online_member_manager->actor_id(dialog_online_member_manager),
&DialogOnlineMemberManager::on_update_dialog_online_member_count_timeout, DialogId(dialog_id_int));
}
void DialogOnlineMemberManager::on_update_dialog_online_member_count_timeout(DialogId dialog_id) {
if (G()->close_flag()) {
return;
}
LOG(INFO) << "Expired timeout for number of online members in " << dialog_id;
bool is_open = td_->messages_manager_->is_dialog_opened(dialog_id);
if (!is_open) {
send_update_chat_online_member_count(dialog_id, 0);
return;
}
if (dialog_id.get_type() == DialogType::Channel && !td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
auto participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
auto has_hidden_participants = td_->contacts_manager_->get_channel_effective_has_hidden_participants(
dialog_id.get_channel_id(), "on_update_dialog_online_member_count_timeout");
if (participant_count == 0 || participant_count >= 195 || has_hidden_participants) {
td_->create_handler<GetOnlinesQuery>()->send(dialog_id);
} else {
td_->contacts_manager_->get_channel_participants(dialog_id.get_channel_id(),
td_api::make_object<td_api::supergroupMembersFilterRecent>(),
string(), 0, 200, 200, Auto());
}
return;
}
if (dialog_id.get_type() == DialogType::Chat) {
// we need actual online status state, so we need to reget chat participants
td_->contacts_manager_->repair_chat_participants(dialog_id.get_chat_id());
return;
}
}
void DialogOnlineMemberManager::on_update_dialog_online_member_count(DialogId dialog_id, int32 online_member_count,
bool is_from_server) {
if (td_->auth_manager_->is_bot()) {
return;
}
if (!dialog_id.is_valid()) {
LOG(ERROR) << "Receive number of online members in invalid " << dialog_id;
return;
}
if (td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
LOG_IF(ERROR, online_member_count != 0)
<< "Receive " << online_member_count << " as a number of online members in a channel " << dialog_id;
return;
}
if (online_member_count < 0) {
LOG(ERROR) << "Receive " << online_member_count << " as a number of online members in a " << dialog_id;
return;
}
set_dialog_online_member_count(dialog_id, online_member_count, is_from_server,
"on_update_channel_online_member_count");
}
void DialogOnlineMemberManager::on_dialog_opened(DialogId dialog_id) {
auto online_count_it = dialog_online_member_counts_.find(dialog_id);
if (online_count_it == dialog_online_member_counts_.end()) {
return;
}
auto &info = online_count_it->second;
CHECK(!info.is_update_sent);
if (Time::now() - info.update_time < ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME) {
info.is_update_sent = true;
send_update_chat_online_member_count(dialog_id, info.online_member_count);
}
}
void DialogOnlineMemberManager::on_dialog_closed(DialogId dialog_id) {
auto online_count_it = dialog_online_member_counts_.find(dialog_id);
if (online_count_it != dialog_online_member_counts_.end()) {
auto &info = online_count_it->second;
info.is_update_sent = false;
}
update_dialog_online_member_count_timeout_.set_timeout_in(dialog_id.get(), ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME);
}
void DialogOnlineMemberManager::set_dialog_online_member_count(DialogId dialog_id, int32 online_member_count,
bool is_from_server, const char *source) {
if (td_->auth_manager_->is_bot()) {
return;
}
if (online_member_count < 0) {
LOG(ERROR) << "Receive online_member_count = " << online_member_count << " in " << dialog_id;
online_member_count = 0;
}
switch (dialog_id.get_type()) {
case DialogType::Chat: {
auto participant_count = td_->contacts_manager_->get_chat_participant_count(dialog_id.get_chat_id());
if (online_member_count > participant_count) {
online_member_count = participant_count;
}
break;
}
case DialogType::Channel: {
auto participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
if (participant_count != 0 && online_member_count > participant_count) {
online_member_count = participant_count;
}
break;
}
default:
break;
}
bool is_open = td_->messages_manager_->is_dialog_opened(dialog_id);
auto &info = dialog_online_member_counts_[dialog_id];
LOG(INFO) << "Change number of online members from " << info.online_member_count << " to " << online_member_count
<< " in " << dialog_id << " from " << source;
bool need_update = is_open && (!info.is_update_sent || info.online_member_count != online_member_count);
info.online_member_count = online_member_count;
info.update_time = Time::now();
if (need_update) {
info.is_update_sent = true;
send_update_chat_online_member_count(dialog_id, online_member_count);
}
if (is_open) {
if (is_from_server) {
update_dialog_online_member_count_timeout_.set_timeout_in(dialog_id.get(), ONLINE_MEMBER_COUNT_UPDATE_TIME);
} else {
update_dialog_online_member_count_timeout_.add_timeout_in(dialog_id.get(), ONLINE_MEMBER_COUNT_UPDATE_TIME);
}
}
}
void DialogOnlineMemberManager::send_update_chat_online_member_count(DialogId dialog_id,
int32 online_member_count) const {
if (td_->auth_manager_->is_bot()) {
return;
}
send_closure(
G()->td(), &Td::send_update,
td_api::make_object<td_api::updateChatOnlineMemberCount>(
td_->dialog_manager_->get_chat_id_object(dialog_id, "updateChatOnlineMemberCount"), online_member_count));
}
void DialogOnlineMemberManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
for (const auto &it : dialog_online_member_counts_) {
auto dialog_id = it.first;
if (it.second.is_update_sent && td_->messages_manager_->is_dialog_opened(dialog_id)) {
updates.push_back(td_api::make_object<td_api::updateChatOnlineMemberCount>(
td_->dialog_manager_->get_chat_id_object(dialog_id, "updateChatOnlineMemberCount"),
it.second.online_member_count));
}
}
}
} // namespace td

View File

@ -6,9 +6,14 @@
//
#pragma once
#include "td/telegram/DialogId.h"
#include "td/telegram/td_api.h"
#include "td/actor/actor.h"
#include "td/actor/MultiTimeout.h"
#include "td/utils/common.h"
#include "td/utils/FlatHashMap.h"
namespace td {
@ -18,9 +23,39 @@ class DialogOnlineMemberManager final : public Actor {
public:
DialogOnlineMemberManager(Td *td, ActorShared<> parent);
static constexpr int32 ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME = 30 * 60;
void on_update_dialog_online_member_count(DialogId dialog_id, int32 online_member_count, bool is_from_server);
void on_dialog_opened(DialogId dialog_id);
void on_dialog_closed(DialogId dialog_id);
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
private:
void tear_down() final;
static constexpr int32 ONLINE_MEMBER_COUNT_UPDATE_TIME = 5 * 60;
static void on_update_dialog_online_member_count_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
void set_dialog_online_member_count(DialogId dialog_id, int32 online_member_count, bool is_from_server,
const char *source);
void on_update_dialog_online_member_count_timeout(DialogId dialog_id);
void send_update_chat_online_member_count(DialogId dialog_id, int32 online_member_count) const;
struct OnlineMemberCountInfo {
int32 online_member_count = 0;
double update_time = 0;
bool is_update_sent = false;
};
FlatHashMap<DialogId, OnlineMemberCountInfo, DialogIdHash> dialog_online_member_counts_;
MultiTimeout update_dialog_online_member_count_timeout_{"UpdateDialogOnlineMemberCountTimeout"};
Td *td_;
ActorShared<> parent_;
};

View File

@ -23,6 +23,7 @@
#include "td/telegram/DialogLocation.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/DialogNotificationSettings.hpp"
#include "td/telegram/DialogOnlineMemberManager.h"
#include "td/telegram/DownloadManager.h"
#include "td/telegram/DraftMessage.h"
#include "td/telegram/DraftMessage.hpp"
@ -112,37 +113,6 @@
namespace td {
class GetOnlinesQuery final : public Td::ResultHandler {
DialogId dialog_id_;
public:
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
CHECK(dialog_id.get_type() == DialogType::Channel);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
send_query(G()->net_query_creator().create(telegram_api::messages_getOnlines(std::move(input_peer))));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getOnlines>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
td_->messages_manager_->on_update_dialog_online_member_count(dialog_id_, result->onlines_, true);
}
void on_error(Status status) final {
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetOnlinesQuery");
td_->messages_manager_->on_update_dialog_online_member_count(dialog_id_, 0, true);
}
};
class GetDialogQuery final : public Td::ResultHandler {
DialogId dialog_id_;
@ -5962,9 +5932,6 @@ MessagesManager::MessagesManager(Td *td, ActorShared<> parent)
active_dialog_action_timeout_.set_callback(on_active_dialog_action_timeout_callback);
active_dialog_action_timeout_.set_callback_data(static_cast<void *>(this));
update_dialog_online_member_count_timeout_.set_callback(on_update_dialog_online_member_count_timeout_callback);
update_dialog_online_member_count_timeout_.set_callback_data(static_cast<void *>(this));
preload_folder_dialog_list_timeout_.set_callback(on_preload_folder_dialog_list_timeout_callback);
preload_folder_dialog_list_timeout_.set_callback_data(static_cast<void *>(this));
@ -5985,8 +5952,8 @@ MessagesManager::~MessagesManager() {
active_get_channel_differences_, get_channel_difference_to_log_event_id_, channel_get_difference_retry_timeouts_,
is_channel_difference_finished_, expected_channel_pts_, expected_channel_max_message_id_, resolved_usernames_,
inaccessible_resolved_usernames_, dialog_bot_command_message_ids_, message_full_id_to_file_source_id_,
last_outgoing_forwarded_message_date_, dialog_viewed_messages_, dialog_online_member_counts_,
previous_repaired_read_inbox_max_message_id_, failed_to_load_dialogs_);
last_outgoing_forwarded_message_date_, dialog_viewed_messages_, previous_repaired_read_inbox_max_message_id_,
failed_to_load_dialogs_);
}
MessagesManager::AddDialogData::AddDialogData(int32 dependent_dialog_count, unique_ptr<Message> &&last_message,
@ -6097,17 +6064,6 @@ void MessagesManager::on_active_dialog_action_timeout_callback(void *messages_ma
DialogId(dialog_id_int));
}
void MessagesManager::on_update_dialog_online_member_count_timeout_callback(void *messages_manager_ptr,
int64 dialog_id_int) {
if (G()->close_flag()) {
return;
}
auto messages_manager = static_cast<MessagesManager *>(messages_manager_ptr);
send_closure_later(messages_manager->actor_id(messages_manager),
&MessagesManager::on_update_dialog_online_member_count_timeout, DialogId(dialog_id_int));
}
void MessagesManager::on_preload_folder_dialog_list_timeout_callback(void *messages_manager_ptr, int64 folder_id_int) {
if (G()->close_flag()) {
return;
@ -7375,32 +7331,6 @@ void MessagesManager::on_update_channel_max_unavailable_message_id(ChannelId cha
set_dialog_max_unavailable_message_id(dialog_id, max_unavailable_message_id, true, source);
}
void MessagesManager::on_update_dialog_online_member_count(DialogId dialog_id, int32 online_member_count,
bool is_from_server) {
if (td_->auth_manager_->is_bot()) {
return;
}
if (!dialog_id.is_valid()) {
LOG(ERROR) << "Receive number of online members in invalid " << dialog_id;
return;
}
if (td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
LOG_IF(ERROR, online_member_count != 0)
<< "Receive " << online_member_count << " as a number of online members in a channel " << dialog_id;
return;
}
if (online_member_count < 0) {
LOG(ERROR) << "Receive " << online_member_count << " as a number of online members in a " << dialog_id;
return;
}
set_dialog_online_member_count(dialog_id, online_member_count, is_from_server,
"on_update_channel_online_member_count");
}
void MessagesManager::on_update_delete_scheduled_messages(DialogId dialog_id,
vector<ScheduledServerMessageId> &&server_message_ids) {
if (td_->auth_manager_->is_bot()) {
@ -12888,94 +12818,6 @@ void MessagesManager::set_dialog_max_unavailable_message_id(DialogId dialog_id,
}
}
void MessagesManager::set_dialog_online_member_count(DialogId dialog_id, int32 online_member_count, bool is_from_server,
const char *source) {
if (td_->auth_manager_->is_bot()) {
return;
}
Dialog *d = get_dialog(dialog_id);
if (d == nullptr) {
return;
}
if (online_member_count < 0) {
LOG(ERROR) << "Receive online_member_count = " << online_member_count << " in " << dialog_id;
online_member_count = 0;
}
switch (dialog_id.get_type()) {
case DialogType::Chat: {
auto participant_count = td_->contacts_manager_->get_chat_participant_count(dialog_id.get_chat_id());
if (online_member_count > participant_count) {
online_member_count = participant_count;
}
break;
}
case DialogType::Channel: {
auto participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
if (participant_count != 0 && online_member_count > participant_count) {
online_member_count = participant_count;
}
break;
}
default:
break;
}
auto &info = dialog_online_member_counts_[dialog_id];
LOG(INFO) << "Change number of online members from " << info.online_member_count << " to " << online_member_count
<< " in " << dialog_id << " from " << source;
bool need_update = d->open_count > 0 && (!info.is_update_sent || info.online_member_count != online_member_count);
info.online_member_count = online_member_count;
info.update_time = Time::now();
if (need_update) {
info.is_update_sent = true;
send_update_chat_online_member_count(dialog_id, online_member_count);
}
if (d->open_count > 0) {
if (is_from_server) {
update_dialog_online_member_count_timeout_.set_timeout_in(dialog_id.get(), ONLINE_MEMBER_COUNT_UPDATE_TIME);
} else {
update_dialog_online_member_count_timeout_.add_timeout_in(dialog_id.get(), ONLINE_MEMBER_COUNT_UPDATE_TIME);
}
}
}
void MessagesManager::on_update_dialog_online_member_count_timeout(DialogId dialog_id) {
if (G()->close_flag()) {
return;
}
LOG(INFO) << "Expired timeout for number of online members in " << dialog_id;
Dialog *d = get_dialog(dialog_id);
CHECK(d != nullptr);
if (d->open_count == 0) {
send_update_chat_online_member_count(dialog_id, 0);
return;
}
if (dialog_id.get_type() == DialogType::Channel && !td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
auto participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
auto has_hidden_participants = td_->contacts_manager_->get_channel_effective_has_hidden_participants(
dialog_id.get_channel_id(), "on_update_dialog_online_member_count_timeout");
if (participant_count == 0 || participant_count >= 195 || has_hidden_participants) {
td_->create_handler<GetOnlinesQuery>()->send(dialog_id);
} else {
td_->contacts_manager_->get_channel_participants(dialog_id.get_channel_id(),
td_api::make_object<td_api::supergroupMembersFilterRecent>(),
string(), 0, 200, 200, Auto());
}
return;
}
if (dialog_id.get_type() == DialogType::Chat) {
// we need actual online status state, so we need to reget chat participants
td_->contacts_manager_->repair_chat_participants(dialog_id.get_chat_id());
return;
}
}
void MessagesManager::on_update_viewed_messages_timeout(DialogId dialog_id) {
if (G()->close_flag()) {
return;
@ -20411,15 +20253,7 @@ void MessagesManager::open_dialog(Dialog *d) {
}
if (!td_->auth_manager_->is_bot()) {
auto online_count_it = dialog_online_member_counts_.find(dialog_id);
if (online_count_it != dialog_online_member_counts_.end()) {
auto &info = online_count_it->second;
CHECK(!info.is_update_sent);
if (Time::now() - info.update_time < ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME) {
info.is_update_sent = true;
send_update_chat_online_member_count(dialog_id, info.online_member_count);
}
}
td_->dialog_online_member_manager_->on_dialog_opened(dialog_id);
if (d->has_scheduled_database_messages && !d->is_has_scheduled_database_messages_checked) {
CHECK(G()->use_message_database());
@ -20512,12 +20346,7 @@ void MessagesManager::close_dialog(Dialog *d) {
send_update_chat_read_inbox(d, false, "close_dialog");
}
auto online_count_it = dialog_online_member_counts_.find(dialog_id);
if (online_count_it != dialog_online_member_counts_.end()) {
auto &info = online_count_it->second;
info.is_update_sent = false;
}
update_dialog_online_member_count_timeout_.set_timeout_in(dialog_id.get(), ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME);
td_->dialog_online_member_manager_->on_dialog_closed(dialog_id);
}
}
@ -30304,16 +30133,6 @@ void MessagesManager::send_update_chat_position(DialogListId dialog_list_id, con
std::move(position)));
}
void MessagesManager::send_update_chat_online_member_count(DialogId dialog_id, int32 online_member_count) const {
if (td_->auth_manager_->is_bot()) {
return;
}
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateChatOnlineMemberCount>(
get_chat_id_object(dialog_id, "updateChatOnlineMemberCount"), online_member_count));
}
void MessagesManager::send_update_secret_chats_with_user_action_bar(const Dialog *d) const {
if (td_->auth_manager_->is_bot()) {
return;
@ -40341,14 +40160,6 @@ void MessagesManager::get_current_state(vector<td_api::object_ptr<td_api::Update
get_chat_positions_object(d)));
}
updates.push_back(std::move(update));
if (d->open_count > 0) {
auto info_it = dialog_online_member_counts_.find(dialog_id);
if (info_it != dialog_online_member_counts_.end() && info_it->second.is_update_sent) {
updates.push_back(td_api::make_object<td_api::updateChatOnlineMemberCount>(
get_chat_id_object(dialog_id, "updateChatOnlineMemberCount"), info_it->second.online_member_count));
}
}
});
append(updates, std::move(last_message_updates));
}

View File

@ -132,8 +132,6 @@ class MessagesManager final : public Actor {
static constexpr int32 SEND_MESSAGE_FLAG_UPDATE_STICKER_SETS_ORDER = 1 << 15;
static constexpr int32 SEND_MESSAGE_FLAG_INVERT_MEDIA = 1 << 16;
static constexpr int32 ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME = 30 * 60;
MessagesManager(Td *td, ActorShared<> parent);
MessagesManager(const MessagesManager &) = delete;
MessagesManager &operator=(const MessagesManager &) = delete;
@ -344,8 +342,6 @@ class MessagesManager final : public Actor {
void on_update_channel_max_unavailable_message_id(ChannelId channel_id, MessageId max_unavailable_message_id,
const char *source);
void on_update_dialog_online_member_count(DialogId dialog_id, int32 online_member_count, bool is_from_server);
void on_update_delete_scheduled_messages(DialogId dialog_id, vector<ScheduledServerMessageId> &&server_message_ids);
void on_update_created_public_broadcasts(vector<ChannelId> channel_ids);
@ -1676,8 +1672,6 @@ class MessagesManager final : public Actor {
static constexpr int32 AUTH_NOTIFICATION_ID_CACHE_TIME = 7 * 86400;
static constexpr size_t MAX_SAVED_AUTH_NOTIFICATION_IDS = 100;
static constexpr int32 ONLINE_MEMBER_COUNT_UPDATE_TIME = 5 * 60;
static constexpr int32 MAX_RESEND_DELAY = 86400; // seconds, some resonable limit
static constexpr int32 SCHEDULE_WHEN_ONLINE_DATE = 2147483646;
@ -2141,11 +2135,6 @@ class MessagesManager final : public Actor {
void set_dialog_max_unavailable_message_id(DialogId dialog_id, MessageId max_unavailable_message_id, bool from_update,
const char *source);
void set_dialog_online_member_count(DialogId dialog_id, int32 online_member_count, bool is_from_server,
const char *source);
void on_update_dialog_online_member_count_timeout(DialogId dialog_id);
void on_update_viewed_messages_timeout(DialogId dialog_id);
void on_send_update_chat_read_inbox_timeout(DialogId dialog_id);
@ -2426,8 +2415,6 @@ class MessagesManager final : public Actor {
void send_update_chat_position(DialogListId dialog_list_id, const Dialog *d, const char *source) const;
void send_update_chat_online_member_count(DialogId dialog_id, int32 online_member_count) const;
void send_update_secret_chats_with_user_action_bar(const Dialog *d) const;
void send_update_chat_action_bar(Dialog *d);
@ -3052,8 +3039,6 @@ class MessagesManager final : public Actor {
static void on_active_dialog_action_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
static void on_update_dialog_online_member_count_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
static void on_preload_folder_dialog_list_timeout_callback(void *messages_manager_ptr, int64 folder_id_int);
static void on_update_viewed_messages_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
@ -3490,7 +3475,6 @@ class MessagesManager final : public Actor {
MultiTimeout dialog_unmute_timeout_{"DialogUnmuteTimeout"};
MultiTimeout pending_send_dialog_action_timeout_{"PendingSendDialogActionTimeout"};
MultiTimeout active_dialog_action_timeout_{"ActiveDialogActionTimeout"};
MultiTimeout update_dialog_online_member_count_timeout_{"UpdateDialogOnlineMemberCountTimeout"};
MultiTimeout preload_folder_dialog_list_timeout_{"PreloadFolderDialogListTimeout"};
MultiTimeout update_viewed_messages_timeout_{"UpdateViewedMessagesTimeout"};
MultiTimeout send_update_chat_read_inbox_timeout_{"SendUpdateChatReadInboxTimeout"};
@ -3605,13 +3589,6 @@ class MessagesManager final : public Actor {
};
FlatHashMap<DialogId, unique_ptr<ViewedMessagesInfo>, DialogIdHash> dialog_viewed_messages_;
struct OnlineMemberCountInfo {
int32 online_member_count = 0;
double update_time = 0;
bool is_update_sent = false;
};
FlatHashMap<DialogId, OnlineMemberCountInfo, DialogIdHash> dialog_online_member_counts_;
struct ReactionsToReload {
FlatHashSet<MessageId, MessageIdHash> message_ids;
bool is_request_sent = false;

View File

@ -4429,6 +4429,8 @@ void Td::on_request(uint64 id, const td_api::getCurrentState &request) {
messages_manager_->get_current_state(updates);
dialog_online_member_manager_->get_current_state(updates);
notification_manager_->get_current_state(updates);
story_manager_->get_current_state(updates);