Rename DialogOnlineMemberManager to DialogParticipantManager.

This commit is contained in:
levlam 2024-01-08 14:22:44 +03:00
parent 55faa7ad0b
commit b579fcd3e0
8 changed files with 46 additions and 48 deletions

View File

@ -333,7 +333,7 @@ set(TDLIB_SOURCE
td/telegram/DialogLocation.cpp
td/telegram/DialogManager.cpp
td/telegram/DialogNotificationSettings.cpp
td/telegram/DialogOnlineMemberManager.cpp
td/telegram/DialogParticipantManager.cpp
td/telegram/DialogParticipant.cpp
td/telegram/DialogParticipantFilter.cpp
td/telegram/DialogSource.cpp
@ -615,7 +615,7 @@ set(TDLIB_SOURCE
td/telegram/DialogLocation.h
td/telegram/DialogManager.h
td/telegram/DialogNotificationSettings.h
td/telegram/DialogOnlineMemberManager.h
td/telegram/DialogParticipantManager.h
td/telegram/DialogParticipant.h
td/telegram/DialogParticipantFilter.h
td/telegram/DialogSource.h

View File

@ -292,7 +292,7 @@ function split_file($file, $chunks, $undo) {
'dialog_filter_manager[_(-][^.]|DialogFilterManager' => "DialogFilterManager",
'dialog_invite_link_manager[_(-][^.]|DialogInviteLinkManager' => "DialogInviteLinkManager",
'dialog_manager[_(-][^.]|DialogManager' => "DialogManager",
'dialog_online_member_manager[_(-][^.]|DialogOnlineMemberManager' => "DialogOnlineMemberManager",
'dialog_participant_manager[_(-][^.]|DialogParticipantManager' => "DialogParticipantManager",
'documents_manager[_(-][^.]|DocumentsManager' => "DocumentsManager",
'download_manager[_(-][^.]|DownloadManager' => "DownloadManager",
'file_reference_manager[_(-][^.]|FileReferenceManager|file_references[)]' => 'FileReferenceManager',

View File

@ -19,7 +19,7 @@
#include "td/telegram/DialogInviteLinkManager.h"
#include "td/telegram/DialogLocation.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/DialogOnlineMemberManager.h"
#include "td/telegram/DialogParticipantManager.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/FileReferenceManager.h"
@ -13145,7 +13145,7 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
}
if (participant_count >= 190 || !can_get_participants || has_hidden_participants) {
td_->dialog_online_member_manager_->on_update_dialog_online_member_count(DialogId(channel_id),
td_->dialog_participant_manager_->on_update_dialog_online_member_count(DialogId(channel_id),
channel->online_count_, true);
}
@ -14322,7 +14322,7 @@ void ContactsManager::update_user_online_member_count(UserId user_id) {
for (const auto &it : online_member_dialogs) {
auto dialog_id = it.first;
auto time = it.second;
if (time < now - DialogOnlineMemberManager::ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME) {
if (time < now - DialogParticipantManager::ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME) {
expired_dialog_ids.push_back(dialog_id);
continue;
}
@ -14402,7 +14402,7 @@ void ContactsManager::update_dialog_online_member_count(const vector<DialogParti
}
}
}
td_->dialog_online_member_manager_->on_update_dialog_online_member_count(dialog_id, online_member_count,
td_->dialog_participant_manager_->on_update_dialog_online_member_count(dialog_id, online_member_count,
is_from_server);
}

View File

@ -4,7 +4,7 @@
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "td/telegram/DialogOnlineMemberManager.h"
#include "td/telegram/DialogParticipantManager.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
@ -42,37 +42,36 @@ class GetOnlinesQuery final : public Td::ResultHandler {
}
auto result = result_ptr.move_as_ok();
td_->dialog_online_member_manager_->on_update_dialog_online_member_count(dialog_id_, result->onlines_, true);
td_->dialog_participant_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);
td_->dialog_participant_manager_->on_update_dialog_online_member_count(dialog_id_, 0, true);
}
};
DialogOnlineMemberManager::DialogOnlineMemberManager(Td *td, ActorShared<> parent)
: td_(td), parent_(std::move(parent)) {
DialogParticipantManager::DialogParticipantManager(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() {
void DialogParticipantManager::tear_down() {
parent_.reset();
}
void DialogOnlineMemberManager::on_update_dialog_online_member_count_timeout_callback(
void *dialog_online_member_manager_ptr, int64 dialog_id_int) {
void DialogParticipantManager::on_update_dialog_online_member_count_timeout_callback(
void *dialog_participant_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));
auto dialog_participant_manager = static_cast<DialogParticipantManager *>(dialog_participant_manager_ptr);
send_closure_later(dialog_participant_manager->actor_id(dialog_participant_manager),
&DialogParticipantManager::on_update_dialog_online_member_count_timeout, DialogId(dialog_id_int));
}
void DialogOnlineMemberManager::on_update_dialog_online_member_count_timeout(DialogId dialog_id) {
void DialogParticipantManager::on_update_dialog_online_member_count_timeout(DialogId dialog_id) {
if (G()->close_flag()) {
return;
}
@ -104,7 +103,7 @@ void DialogOnlineMemberManager::on_update_dialog_online_member_count_timeout(Dia
}
}
void DialogOnlineMemberManager::on_update_dialog_online_member_count(DialogId dialog_id, int32 online_member_count,
void DialogParticipantManager::on_update_dialog_online_member_count(DialogId dialog_id, int32 online_member_count,
bool is_from_server) {
if (td_->auth_manager_->is_bot()) {
return;
@ -130,7 +129,7 @@ void DialogOnlineMemberManager::on_update_dialog_online_member_count(DialogId di
"on_update_channel_online_member_count");
}
void DialogOnlineMemberManager::on_dialog_opened(DialogId dialog_id) {
void DialogParticipantManager::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;
@ -143,7 +142,7 @@ void DialogOnlineMemberManager::on_dialog_opened(DialogId dialog_id) {
}
}
void DialogOnlineMemberManager::on_dialog_closed(DialogId dialog_id) {
void DialogParticipantManager::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;
@ -152,7 +151,7 @@ void DialogOnlineMemberManager::on_dialog_closed(DialogId dialog_id) {
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,
void DialogParticipantManager::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;
@ -203,7 +202,7 @@ void DialogOnlineMemberManager::set_dialog_online_member_count(DialogId dialog_i
}
}
void DialogOnlineMemberManager::send_update_chat_online_member_count(DialogId dialog_id,
void DialogParticipantManager::send_update_chat_online_member_count(DialogId dialog_id,
int32 online_member_count) const {
if (td_->auth_manager_->is_bot()) {
return;
@ -215,7 +214,7 @@ void DialogOnlineMemberManager::send_update_chat_online_member_count(DialogId di
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 {
void DialogParticipantManager::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)) {

View File

@ -19,9 +19,9 @@ namespace td {
class Td;
class DialogOnlineMemberManager final : public Actor {
class DialogParticipantManager final : public Actor {
public:
DialogOnlineMemberManager(Td *td, ActorShared<> parent);
DialogParticipantManager(Td *td, ActorShared<> parent);
static constexpr int32 ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME = 30 * 60;
@ -38,7 +38,7 @@ class DialogOnlineMemberManager final : public Actor {
static constexpr int32 ONLINE_MEMBER_COUNT_UPDATE_TIME = 5 * 60;
static void on_update_dialog_online_member_count_timeout_callback(void *dialog_online_member_manager_ptr,
static void on_update_dialog_online_member_count_timeout_callback(void *dialog_participant_manager_ptr,
int64 dialog_id_int);
void set_dialog_online_member_count(DialogId dialog_id, int32 online_member_count, bool is_from_server,

View File

@ -25,7 +25,7 @@
#include "td/telegram/DialogLocation.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/DialogNotificationSettings.hpp"
#include "td/telegram/DialogOnlineMemberManager.h"
#include "td/telegram/DialogParticipantManager.h"
#include "td/telegram/DownloadManager.h"
#include "td/telegram/DraftMessage.h"
#include "td/telegram/DraftMessage.hpp"
@ -18901,7 +18901,7 @@ void MessagesManager::open_dialog(Dialog *d) {
}
if (!td_->auth_manager_->is_bot()) {
td_->dialog_online_member_manager_->on_dialog_opened(dialog_id);
td_->dialog_participant_manager_->on_dialog_opened(dialog_id);
if (d->has_scheduled_database_messages && !d->is_has_scheduled_database_messages_checked) {
CHECK(G()->use_message_database());
@ -18994,7 +18994,7 @@ void MessagesManager::close_dialog(Dialog *d) {
send_update_chat_read_inbox(d, false, "close_dialog");
}
td_->dialog_online_member_manager_->on_dialog_closed(dialog_id);
td_->dialog_participant_manager_->on_dialog_closed(dialog_id);
}
}

View File

@ -46,9 +46,9 @@
#include "td/telegram/DialogListId.h"
#include "td/telegram/DialogLocation.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/DialogOnlineMemberManager.h"
#include "td/telegram/DialogParticipant.h"
#include "td/telegram/DialogParticipantFilter.h"
#include "td/telegram/DialogParticipantManager.h"
#include "td/telegram/DialogSource.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/DownloadManager.h"
@ -3301,8 +3301,8 @@ void Td::dec_actor_refcnt() {
LOG(DEBUG) << "DialogInviteLinkManager was cleared" << timer;
dialog_manager_.reset();
LOG(DEBUG) << "DialogManager was cleared" << timer;
dialog_online_member_manager_.reset();
LOG(DEBUG) << "DialogOnlineMemberManager was cleared" << timer;
dialog_participant_manager_.reset();
LOG(DEBUG) << "DialogParticipantManager was cleared" << timer;
documents_manager_.reset();
LOG(DEBUG) << "DocumentsManager was cleared" << timer;
download_manager_.reset();
@ -3524,8 +3524,8 @@ void Td::clear() {
LOG(DEBUG) << "DialogInviteLinkManager actor was cleared" << timer;
dialog_manager_actor_.reset();
LOG(DEBUG) << "DialogManager actor was cleared" << timer;
dialog_online_member_manager_actor_.reset();
LOG(DEBUG) << "DialogOnlineMemberManager actor was cleared" << timer;
dialog_participant_manager_actor_.reset();
LOG(DEBUG) << "DialogParticipantManager actor was cleared" << timer;
download_manager_actor_.reset();
LOG(DEBUG) << "DownloadManager actor was cleared" << timer;
file_manager_actor_.reset();
@ -4031,9 +4031,8 @@ void Td::init_managers() {
dialog_manager_ = make_unique<DialogManager>(this, create_reference());
dialog_manager_actor_ = register_actor("DialogManager", dialog_manager_.get());
G()->set_dialog_manager(dialog_manager_actor_.get());
dialog_online_member_manager_ = make_unique<DialogOnlineMemberManager>(this, create_reference());
dialog_online_member_manager_actor_ =
register_actor("DialogOnlineMemberManager", dialog_online_member_manager_.get());
dialog_participant_manager_ = make_unique<DialogParticipantManager>(this, create_reference());
dialog_participant_manager_actor_ = register_actor("DialogParticipantManager", dialog_participant_manager_.get());
download_manager_ = DownloadManager::create(td::make_unique<DownloadManagerCallback>(this, create_reference()));
download_manager_actor_ = register_actor("DownloadManager", download_manager_.get());
G()->set_download_manager(download_manager_actor_.get());
@ -4460,7 +4459,7 @@ 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);
dialog_participant_manager_->get_current_state(updates);
notification_manager_->get_current_state(updates);

View File

@ -57,7 +57,7 @@ class DialogActionManager;
class DialogFilterManager;
class DialogInviteLinkManager;
class DialogManager;
class DialogOnlineMemberManager;
class DialogParticipantManager;
class DocumentsManager;
class DownloadManager;
class FileManager;
@ -188,8 +188,8 @@ class Td final : public Actor {
ActorOwn<DialogInviteLinkManager> dialog_invite_link_manager_actor_;
unique_ptr<DialogManager> dialog_manager_;
ActorOwn<DialogManager> dialog_manager_actor_;
unique_ptr<DialogOnlineMemberManager> dialog_online_member_manager_;
ActorOwn<DialogOnlineMemberManager> dialog_online_member_manager_actor_;
unique_ptr<DialogParticipantManager> dialog_participant_manager_;
ActorOwn<DialogParticipantManager> dialog_participant_manager_actor_;
unique_ptr<DownloadManager> download_manager_;
ActorOwn<DownloadManager> download_manager_actor_;
unique_ptr<FileManager> file_manager_;