Move get_input_dialog_id to DialogManager.

This commit is contained in:
levlam 2024-01-04 16:20:15 +03:00
parent 32898dbe88
commit b97fa08e62
5 changed files with 20 additions and 18 deletions

View File

@ -116,7 +116,7 @@ Result<unique_ptr<DialogFilter>> DialogFilter::create_dialog_filter(Td *td, Dial
continue;
}
input_dialog_ids.push_back(td->messages_manager_->get_input_dialog_id(DialogId(chat_id)));
input_dialog_ids.push_back(td->dialog_manager_->get_input_dialog_id(DialogId(chat_id)));
}
};
add_chats(dialog_filter->pinned_dialog_ids_, filter->pinned_chat_ids_);

View File

@ -31,6 +31,16 @@ DialogId DialogManager::get_my_dialog_id() const {
return DialogId(td_->contacts_manager_->get_my_id());
}
InputDialogId DialogManager::get_input_dialog_id(DialogId dialog_id) const {
auto input_peer = get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr || input_peer->get_id() == telegram_api::inputPeerSelf::ID ||
input_peer->get_id() == telegram_api::inputPeerEmpty::ID) {
return InputDialogId(dialog_id);
} else {
return InputDialogId(input_peer);
}
}
tl_object_ptr<telegram_api::InputPeer> DialogManager::get_input_peer(DialogId dialog_id,
AccessRights access_rights) const {
switch (dialog_id.get_type()) {

View File

@ -12,6 +12,7 @@
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogParticipant.h"
#include "td/telegram/EmojiStatus.h"
#include "td/telegram/InputDialogId.h"
#include "td/telegram/NotificationSettingsScope.h"
#include "td/telegram/Photo.h"
#include "td/telegram/td_api.h"
@ -33,6 +34,8 @@ class DialogManager final : public Actor {
DialogId get_my_dialog_id() const;
InputDialogId get_input_dialog_id(DialogId dialog_id) const;
tl_object_ptr<telegram_api::InputPeer> get_input_peer(DialogId dialog_id, AccessRights access_rights) const;
static tl_object_ptr<telegram_api::InputPeer> get_input_peer_force(DialogId dialog_id);

View File

@ -18749,16 +18749,6 @@ td_api::object_ptr<td_api::messageLinkInfo> MessagesManager::get_message_link_in
for_album);
}
InputDialogId MessagesManager::get_input_dialog_id(DialogId dialog_id) const {
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr || input_peer->get_id() == telegram_api::inputPeerSelf::ID ||
input_peer->get_id() == telegram_api::inputPeerEmpty::ID) {
return InputDialogId(dialog_id);
} else {
return InputDialogId(input_peer);
}
}
Status MessagesManager::can_add_dialog_to_filter(DialogId dialog_id) {
if (!dialog_id.is_valid()) {
return Status::Error(400, "Invalid chat identifier specified");
@ -18977,8 +18967,8 @@ Status MessagesManager::toggle_dialog_is_pinned(DialogListId dialog_list_id, Dia
}
if (dialog_list_id.is_filter()) {
return td_->dialog_filter_manager_->set_dialog_is_pinned(dialog_list_id.get_filter_id(),
get_input_dialog_id(dialog_id), is_pinned);
return td_->dialog_filter_manager_->set_dialog_is_pinned(
dialog_list_id.get_filter_id(), td_->dialog_manager_->get_input_dialog_id(dialog_id), is_pinned);
}
CHECK(dialog_list_id.is_folder());
@ -19111,7 +19101,8 @@ Status MessagesManager::set_pinned_dialogs(DialogListId dialog_list_id, vector<D
if (dialog_list_id.is_filter()) {
return td_->dialog_filter_manager_->set_pinned_dialog_ids(
dialog_list_id.get_filter_id(),
transform(dialog_ids, [this](DialogId dialog_id) { return get_input_dialog_id(dialog_id); }),
transform(dialog_ids,
[this](DialogId dialog_id) { return td_->dialog_manager_->get_input_dialog_id(dialog_id); }),
server_old_dialog_ids != server_new_dialog_ids);
}
@ -33352,8 +33343,8 @@ void MessagesManager::add_dialog_to_list(DialogId dialog_id, DialogListId dialog
}
if (dialog_list_id.is_filter()) {
return promise.set_result(
td_->dialog_filter_manager_->add_dialog(dialog_list_id.get_filter_id(), get_input_dialog_id(dialog_id)));
return promise.set_result(td_->dialog_filter_manager_->add_dialog(
dialog_list_id.get_filter_id(), td_->dialog_manager_->get_input_dialog_id(dialog_id)));
}
CHECK(dialog_list_id.is_folder());

View File

@ -657,8 +657,6 @@ class MessagesManager final : public Actor {
td_api::object_ptr<td_api::messageLinkInfo> get_message_link_info_object(const MessageLinkInfo &info) const;
InputDialogId get_input_dialog_id(DialogId dialog_id) const;
bool is_dialog_in_dialog_list(DialogId dialog_id) const;
Status can_add_dialog_to_filter(DialogId dialog_id);