Move ContactsManager proxy methods to DialogManager.

This commit is contained in:
levlam 2024-01-03 23:07:50 +03:00
parent 36f6a97b58
commit b2fccc7d9c
38 changed files with 1572 additions and 1471 deletions

View File

@ -10,6 +10,7 @@
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/FileReferenceManager.h"
@ -90,7 +91,7 @@ class RequestAppWebViewQuery final : public Td::ResultHandler {
if (!start_parameter.empty()) {
flags |= telegram_api::messages_requestAppWebView::START_PARAM_MASK;
}
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
CHECK(input_peer != nullptr);
auto input_bot_app =
telegram_api::make_object<telegram_api::inputBotAppShortName>(std::move(input_user), web_app_short_name);
@ -140,7 +141,7 @@ class RequestWebViewQuery final : public Td::ResultHandler {
int32 flags = 0;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
CHECK(input_peer != nullptr);
string start_parameter;
@ -179,7 +180,7 @@ class RequestWebViewQuery final : public Td::ResultHandler {
tl_object_ptr<telegram_api::InputPeer> as_input_peer;
if (as_dialog_id.is_valid()) {
as_input_peer = td_->messages_manager_->get_input_peer(as_dialog_id, AccessRights::Write);
as_input_peer = td_->dialog_manager_->get_input_peer(as_dialog_id, AccessRights::Write);
if (as_input_peer != nullptr) {
flags |= telegram_api::messages_requestWebView::SEND_AS_MASK;
}
@ -203,7 +204,7 @@ class RequestWebViewQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "RequestWebViewQuery")) {
if (!td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "RequestWebViewQuery")) {
if (from_attach_menu_) {
td_->attach_menu_manager_->reload_attach_menu_bots(Promise<Unit>());
}
@ -220,7 +221,7 @@ class ProlongWebViewQuery final : public Td::ResultHandler {
const MessageInputReplyTo &input_reply_to, bool silent, DialogId as_dialog_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto r_input_user = td_->contacts_manager_->get_input_user(bot_user_id);
if (input_peer == nullptr || r_input_user.is_error()) {
return;
@ -237,7 +238,7 @@ class ProlongWebViewQuery final : public Td::ResultHandler {
tl_object_ptr<telegram_api::InputPeer> as_input_peer;
if (as_dialog_id.is_valid()) {
as_input_peer = td_->messages_manager_->get_input_peer(as_dialog_id, AccessRights::Write);
as_input_peer = td_->dialog_manager_->get_input_peer(as_dialog_id, AccessRights::Write);
if (as_input_peer != nullptr) {
flags |= telegram_api::messages_prolongWebView::SEND_AS_MASK;
}
@ -261,7 +262,7 @@ class ProlongWebViewQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ProlongWebViewQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "ProlongWebViewQuery");
}
};
@ -822,7 +823,7 @@ void AttachMenuManager::request_app_web_view(DialogId dialog_id, UserId bot_user
string &&start_parameter,
const td_api::object_ptr<td_api::themeParameters> &theme,
string &&platform, bool allow_write_access, Promise<string> &&promise) {
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read) ||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read) ||
dialog_id.get_type() == DialogType::SecretChat) {
dialog_id = DialogId(bot_user_id);
}
@ -859,7 +860,7 @@ void AttachMenuManager::request_web_view(DialogId dialog_id, UserId bot_user_id,
UNREACHABLE();
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
return promise.set_error(Status::Error(400, "Have no write access to the chat"));
}

View File

@ -9,6 +9,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/MessagesManager.h"
@ -75,7 +76,7 @@ class SaveAutoSaveSettingsQuery final : public Td::ResultHandler {
flags |= telegram_api::account_saveAutoSaveSettings::BROADCASTS_MASK;
} else {
flags |= telegram_api::account_saveAutoSaveSettings::PEER_MASK;
input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
if (dialog_id.get_type() == DialogType::SecretChat) {
return on_error(Status::Error(400, "Can't set autosave settings for secret chats"));

View File

@ -11,6 +11,7 @@
#include "td/telegram/BackgroundType.hpp"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/DocumentsManager.hpp"
@ -122,7 +123,7 @@ class SetChatWallPaperQuery final : public Td::ResultHandler {
}
int32 flags = 0;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -162,11 +163,11 @@ class SetChatWallPaperQuery final : public Td::ResultHandler {
void on_error(Status status) final {
if (is_remove_) {
td_->messages_manager_->reload_dialog_info_full(dialog_id_, "SetChatWallPaperQuery");
td_->dialog_manager_->reload_dialog_info_full(dialog_id_, "SetChatWallPaperQuery");
} else if (is_revert_ && status.message() == "WALLPAPER_NOT_FOUND") {
return td_->background_manager_->delete_dialog_background(dialog_id_, false, std::move(promise_));
}
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetChatWallPaperQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "SetChatWallPaperQuery");
promise_.set_error(std::move(status));
}
};
@ -740,7 +741,7 @@ Result<DialogId> BackgroundManager::get_background_dialog(DialogId dialog_id) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "set_dialog_background")) {
return Status::Error(400, "Chat not found");
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
return Status::Error(400, "Can't access the chat");
}

View File

@ -9,6 +9,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/LinkManager.h"
#include "td/telegram/MessageId.h"
@ -140,7 +141,7 @@ class GetBoostsStatusQuery final : public Td::ResultHandler {
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(
G()->net_query_creator().create(telegram_api::premium_getBoostsStatus(std::move(input_peer)), {{dialog_id}}));
@ -196,7 +197,7 @@ class GetBoostsStatusQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetBoostsStatusQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetBoostsStatusQuery");
promise_.set_error(std::move(status));
}
};
@ -212,7 +213,7 @@ class ApplyBoostQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, vector<int32> slot_ids) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(
G()->net_query_creator().create(telegram_api::premium_applyBoost(telegram_api::premium_applyBoost::SLOTS_MASK,
@ -232,7 +233,7 @@ class ApplyBoostQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ApplyBoostQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "ApplyBoostQuery");
promise_.set_error(std::move(status));
}
};
@ -248,7 +249,7 @@ class GetBoostsListQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, bool only_gift_codes, const string &offset, int32 limit) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
int32 flags = 0;
if (only_gift_codes) {
@ -282,7 +283,7 @@ class GetBoostsListQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetBoostsListQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetBoostsListQuery");
promise_.set_error(std::move(status));
}
};
@ -298,7 +299,7 @@ class GetUserBoostsQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, UserId user_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
auto r_input_user = td_->contacts_manager_->get_input_user(user_id);
CHECK(r_input_user.is_ok());
@ -330,7 +331,7 @@ class GetUserBoostsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetUserBoostsQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetUserBoostsQuery");
promise_.set_error(std::move(status));
}
};
@ -378,7 +379,7 @@ void BoostManager::get_dialog_boost_status(DialogId dialog_id,
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
@ -390,7 +391,7 @@ void BoostManager::boost_dialog(DialogId dialog_id, vector<int32> slot_ids,
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
if (slot_ids.empty()) {
@ -404,7 +405,7 @@ Result<std::pair<string, bool>> BoostManager::get_dialog_boost_link(DialogId dia
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return Status::Error(400, "Chat not found");
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return Status::Error(400, "Can't access the chat");
}
if (dialog_id.get_type() != DialogType::Channel ||
@ -455,7 +456,7 @@ void BoostManager::get_dialog_boosts(DialogId dialog_id, bool only_gift_codes, c
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boosts")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
if (limit <= 0) {
@ -470,7 +471,7 @@ void BoostManager::get_user_dialog_boosts(DialogId dialog_id, UserId user_id,
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_user_dialog_boosts")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
if (!user_id.is_valid()) {
@ -482,7 +483,7 @@ void BoostManager::get_user_dialog_boosts(DialogId dialog_id, UserId user_id,
void BoostManager::on_update_dialog_boost(DialogId dialog_id, telegram_api::object_ptr<telegram_api::boost> &&boost) {
CHECK(td_->auth_manager_->is_bot());
if (!dialog_id.is_valid() || !td_->messages_manager_->have_dialog_info_force(dialog_id, "on_update_dialog_boost")) {
if (!dialog_id.is_valid() || !td_->dialog_manager_->have_dialog_info_force(dialog_id, "on_update_dialog_boost")) {
LOG(ERROR) << "Receive updateBotChatBoost in " << dialog_id;
return;
}

View File

@ -9,6 +9,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h"
@ -65,7 +66,7 @@ Result<BotCommandScope> BotCommandScope::get_bot_command_scope(Td *td,
if (!td->messages_manager_->have_dialog_force(dialog_id, "get_bot_command_scope")) {
return Status::Error(400, "Chat not found");
}
if (!td->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return Status::Error(400, "Can't access the chat");
}
switch (dialog_id.get_type()) {
@ -93,7 +94,7 @@ Result<BotCommandScope> BotCommandScope::get_bot_command_scope(Td *td,
telegram_api::object_ptr<telegram_api::BotCommandScope> BotCommandScope::get_input_bot_command_scope(
const Td *td) const {
auto input_peer =
dialog_id_.is_valid() ? td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read) : nullptr;
dialog_id_.is_valid() ? td->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read) : nullptr;
auto r_input_user = td->contacts_manager_->get_input_user(user_id_);
auto input_user = r_input_user.is_ok() ? r_input_user.move_as_ok() : nullptr;
switch (type_) {

View File

@ -9,6 +9,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/InlineQueriesManager.h"
#include "td/telegram/MessagesManager.h"
@ -40,7 +41,7 @@ class GetBotCallbackAnswerQuery final : public Td::ResultHandler {
dialog_id_ = dialog_id;
message_id_ = message_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
CHECK(input_peer != nullptr);
int32 flags = 0;
@ -238,7 +239,7 @@ void CallbackQueriesManager::send_callback_query(MessageFullId message_full_id,
auto dialog_id = message_full_id.get_dialog_id();
td_->messages_manager_->have_dialog_force(dialog_id, "send_callback_query");
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
@ -278,7 +279,7 @@ void CallbackQueriesManager::send_get_callback_answer_query(
TRY_STATUS_PROMISE(promise, G()->close_status());
auto dialog_id = message_full_id.get_dialog_id();
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
if (!td_->messages_manager_->have_message_force(message_full_id, "send_callback_query")) {

View File

@ -16,6 +16,7 @@
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogInviteLink.h"
#include "td/telegram/DialogLocation.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/FileReferenceManager.h"
@ -98,7 +99,7 @@ class DismissSuggestionQuery final : public Td::ResultHandler {
void send(SuggestedAction action) {
dialog_id_ = action.dialog_id_;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(G()->net_query_creator().create(
@ -115,7 +116,7 @@ class DismissSuggestionQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "DismissSuggestionQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "DismissSuggestionQuery");
promise_.set_error(std::move(status));
}
};
@ -1853,7 +1854,7 @@ class EditChatAboutQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, const string &about) {
dialog_id_ = dialog_id;
about_ = about;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -1885,7 +1886,7 @@ class EditChatAboutQuery final : public Td::ResultHandler {
return;
}
} else {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditChatAboutQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "EditChatAboutQuery");
}
promise_.set_error(std::move(status));
}
@ -2040,7 +2041,7 @@ class ReportChannelSpamQuery final : public Td::ResultHandler {
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
auto input_peer = td_->messages_manager_->get_input_peer(sender_dialog_id, AccessRights::Know);
auto input_peer = td_->dialog_manager_->get_input_peer(sender_dialog_id, AccessRights::Know);
CHECK(input_peer != nullptr);
send_query(G()->net_query_creator().create(telegram_api::channels_reportSpam(
@ -2256,7 +2257,7 @@ class ExportChatInviteQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, const string &title, int32 expire_date, int32 usage_limit, bool creates_join_request,
bool is_permanent) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2305,7 +2306,7 @@ class ExportChatInviteQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ExportChatInviteQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "ExportChatInviteQuery");
promise_.set_error(std::move(status));
}
};
@ -2322,7 +2323,7 @@ class EditChatInviteLinkQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, const string &invite_link, const string &title, int32 expire_date, int32 usage_limit,
bool creates_join_request) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2361,7 +2362,7 @@ class EditChatInviteLinkQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditChatInviteLinkQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "EditChatInviteLinkQuery");
promise_.set_error(std::move(status));
}
};
@ -2377,7 +2378,7 @@ class GetExportedChatInviteQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, const string &invite_link) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2411,7 +2412,7 @@ class GetExportedChatInviteQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetExportedChatInviteQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetExportedChatInviteQuery");
promise_.set_error(std::move(status));
}
};
@ -2428,7 +2429,7 @@ class GetExportedChatInvitesQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, tl_object_ptr<telegram_api::InputUser> &&input_user, bool is_revoked, int32 offset_date,
const string &offset_invite_link, int32 limit) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2476,7 +2477,7 @@ class GetExportedChatInvitesQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetExportedChatInvitesQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetExportedChatInvitesQuery");
promise_.set_error(std::move(status));
}
};
@ -2492,7 +2493,7 @@ class GetChatAdminWithInvitesQuery final : public Td::ResultHandler {
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2526,7 +2527,7 @@ class GetChatAdminWithInvitesQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetChatAdminWithInvitesQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetChatAdminWithInvitesQuery");
promise_.set_error(std::move(status));
}
};
@ -2542,7 +2543,7 @@ class GetChatInviteImportersQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, const string &invite_link, int32 offset_date, UserId offset_user_id, int32 limit) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2593,7 +2594,7 @@ class GetChatInviteImportersQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetChatInviteImportersQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetChatInviteImportersQuery");
promise_.set_error(std::move(status));
}
};
@ -2614,7 +2615,7 @@ class GetChatJoinRequestsQuery final : public Td::ResultHandler {
is_full_list_ =
invite_link.empty() && query.empty() && offset_date == 0 && !offset_user_id.is_valid() && limit >= 3;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2676,7 +2677,7 @@ class GetChatJoinRequestsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetChatJoinRequestsQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetChatJoinRequestsQuery");
promise_.set_error(std::move(status));
}
};
@ -2691,7 +2692,7 @@ class HideChatJoinRequestQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, UserId user_id, bool approve) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2718,7 +2719,7 @@ class HideChatJoinRequestQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "HideChatJoinRequestQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "HideChatJoinRequestQuery");
promise_.set_error(std::move(status));
}
};
@ -2733,7 +2734,7 @@ class HideAllChatJoinRequestsQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, const string &invite_link, bool approve) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2761,7 +2762,7 @@ class HideAllChatJoinRequestsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "HideAllChatJoinRequestsQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "HideAllChatJoinRequestsQuery");
promise_.set_error(std::move(status));
}
};
@ -2777,7 +2778,7 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, const string &invite_link) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2837,7 +2838,7 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "RevokeChatInviteLinkQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "RevokeChatInviteLinkQuery");
promise_.set_error(std::move(status));
}
};
@ -2852,7 +2853,7 @@ class DeleteExportedChatInviteQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, const string &invite_link) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2871,7 +2872,7 @@ class DeleteExportedChatInviteQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteExportedChatInviteQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "DeleteExportedChatInviteQuery");
promise_.set_error(std::move(status));
}
};
@ -2886,7 +2887,7 @@ class DeleteRevokedExportedChatInvitesQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, tl_object_ptr<telegram_api::InputUser> &&input_user) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -2905,7 +2906,7 @@ class DeleteRevokedExportedChatInvitesQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteRevokedExportedChatInvitesQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "DeleteRevokedExportedChatInvitesQuery");
promise_.set_error(std::move(status));
}
};
@ -8896,7 +8897,7 @@ void ContactsManager::report_channel_spam(ChannelId channel_id, const vector<Mes
auto sender_dialog_id = td_->messages_manager_->get_dialog_message_sender({DialogId(channel_id), message_id});
CHECK(sender_dialog_id.get_type() != DialogType::SecretChat);
if (sender_dialog_id.is_valid() && sender_dialog_id != DialogId(get_my_id()) &&
td_->messages_manager_->have_input_peer(sender_dialog_id, AccessRights::Know)) {
td_->dialog_manager_->have_input_peer(sender_dialog_id, AccessRights::Know)) {
server_message_ids[sender_dialog_id].push_back(message_id);
}
}
@ -9734,7 +9735,7 @@ void ContactsManager::restrict_channel_participant(ChannelId channel_id, DialogI
return promise.set_error(Status::Error(400, "Not in the chat"));
}
}
auto input_peer = td_->messages_manager_->get_input_peer(participant_dialog_id, AccessRights::Know);
auto input_peer = td_->dialog_manager_->get_input_peer(participant_dialog_id, AccessRights::Know);
if (input_peer == nullptr) {
return promise.set_error(Status::Error(400, "Member not found"));
}
@ -10523,7 +10524,7 @@ void ContactsManager::dismiss_dialog_suggested_action(SuggestedAction action, Pr
if (!td_->messages_manager_->have_dialog(dialog_id)) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
@ -15267,7 +15268,7 @@ void ContactsManager::on_get_chat_participants(tl_object_ptr<telegram_api::ChatP
continue;
}
LOG_IF(ERROR, !td_->messages_manager_->have_dialog_info(dialog_participant.dialog_id_))
LOG_IF(ERROR, !td_->dialog_manager_->have_dialog_info(dialog_participant.dialog_id_))
<< "Have no information about " << dialog_participant.dialog_id_ << " as a member of " << chat_id;
LOG_IF(ERROR, !have_user(dialog_participant.inviter_user_id_))
<< "Have no information about " << dialog_participant.inviter_user_id_ << " as a member of " << chat_id;
@ -16363,7 +16364,7 @@ void ContactsManager::on_view_dialog_active_stories(vector<DialogId> dialog_ids)
if (td::contains(input_dialog_ids, dialog_id)) {
continue;
}
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
continue;
}
@ -17711,7 +17712,7 @@ void ContactsManager::on_update_chat_invite_requester(DialogId dialog_id, UserId
DialogInviteLink invite_link) {
CHECK(td_->auth_manager_->is_bot());
if (date <= 0 || !have_user_force(user_id, "on_update_chat_invite_requester") ||
!td_->messages_manager_->have_dialog_info_force(dialog_id, "on_update_chat_invite_requester")) {
!td_->dialog_manager_->have_dialog_info_force(dialog_id, "on_update_chat_invite_requester")) {
LOG(ERROR) << "Receive invalid updateBotChatInviteRequester by " << user_id << " in " << dialog_id << " at "
<< date;
return;
@ -18964,7 +18965,7 @@ std::pair<int32, vector<DialogId>> ContactsManager::search_among_dialogs(const v
}
rating = -get_user_was_online(u, user_id, unix_time);
} else {
if (!td_->messages_manager_->have_dialog_info(dialog_id)) {
if (!td_->dialog_manager_->have_dialog_info(dialog_id)) {
continue;
}
if (query.empty()) {
@ -19328,7 +19329,7 @@ void ContactsManager::get_channel_participant(ChannelId channel_id, DialogId par
Promise<DialogParticipant> &&promise) {
LOG(INFO) << "Trying to get " << participant_dialog_id << " as member of " << channel_id;
auto input_peer = td_->messages_manager_->get_input_peer(participant_dialog_id, AccessRights::Know);
auto input_peer = td_->dialog_manager_->get_input_peer(participant_dialog_id, AccessRights::Know);
if (input_peer == nullptr) {
return promise.set_error(Status::Error(400, "Member not found"));
}

View File

@ -12,6 +12,7 @@
#include "td/telegram/DialogFilter.h"
#include "td/telegram/DialogFilter.hpp"
#include "td/telegram/DialogFilterInviteLink.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/LinkManager.h"
#include "td/telegram/logevent/LogEvent.h"
@ -356,7 +357,7 @@ class JoinChatlistInviteQuery final : public Td::ResultHandler {
void send(const string &invite_link, vector<DialogId> dialog_ids) {
send_query(G()->net_query_creator().create(telegram_api::chatlists_joinChatlistInvite(
LinkManager::get_dialog_filter_invite_link_slug(invite_link),
td_->messages_manager_->get_input_peers(dialog_ids, AccessRights::Know))));
td_->dialog_manager_->get_input_peers(dialog_ids, AccessRights::Know))));
}
void on_result(BufferSlice packet) final {
@ -416,8 +417,7 @@ class JoinChatlistUpdatesQuery final : public Td::ResultHandler {
void send(DialogFilterId dialog_filter_id, vector<DialogId> dialog_ids) {
send_query(G()->net_query_creator().create(telegram_api::chatlists_joinChatlistUpdates(
dialog_filter_id.get_input_chatlist(),
td_->messages_manager_->get_input_peers(dialog_ids, AccessRights::Know))));
dialog_filter_id.get_input_chatlist(), td_->dialog_manager_->get_input_peers(dialog_ids, AccessRights::Know))));
}
void on_result(BufferSlice packet) final {
@ -944,7 +944,7 @@ void DialogFilterManager::load_dialog_filter(const DialogFilter *dialog_filter,
// TODO load dialogs asynchronously
if (!td_->messages_manager_->have_dialog_force(dialog_id, "load_dialog_filter")) {
if (dialog_id.get_type() == DialogType::SecretChat) {
if (td_->messages_manager_->have_dialog_info_force(dialog_id, "load_dialog_filter")) {
if (td_->dialog_manager_->have_dialog_info_force(dialog_id, "load_dialog_filter")) {
td_->messages_manager_->force_create_dialog(dialog_id, "load_dialog_filter");
}
} else {
@ -1901,7 +1901,7 @@ void DialogFilterManager::create_dialog_filter_invite_link(
if (!td_->messages_manager_->have_dialog_force(dialog_id, "create_dialog_filter_invite_link")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return promise.set_error(Status::Error(400, "Have no access to the chat"));
}
@ -1939,7 +1939,7 @@ void DialogFilterManager::edit_dialog_filter_invite_link(
if (!td_->messages_manager_->have_dialog_force(dialog_id, "edit_dialog_filter_invite_link")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return promise.set_error(Status::Error(400, "Have no access to the chat"));
}
@ -2038,7 +2038,7 @@ void DialogFilterManager::add_dialog_filter_by_invite_link(const string &invite_
if (!td_->messages_manager_->have_dialog_force(dialog_id, "add_dialog_filter_by_invite_link")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Know)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Know)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
}
@ -2072,7 +2072,7 @@ void DialogFilterManager::add_dialog_filter_new_chats(DialogFilterId dialog_filt
if (!td_->messages_manager_->have_dialog_force(dialog_id, "add_dialog_filter_new_chats")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Know)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Know)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
}

View File

@ -6,6 +6,15 @@
//
#include "td/telegram/DialogManager.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ChannelId.h"
#include "td/telegram/ChatId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/SecretChatId.h"
#include "td/telegram/Td.h"
#include "td/telegram/UserId.h"
namespace td {
DialogManager::DialogManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
@ -15,4 +24,692 @@ void DialogManager::tear_down() {
parent_.reset();
}
DialogId DialogManager::get_my_dialog_id() const {
return DialogId(td_->contacts_manager_->get_my_id());
}
tl_object_ptr<telegram_api::InputPeer> DialogManager::get_input_peer(DialogId dialog_id,
AccessRights access_rights) const {
switch (dialog_id.get_type()) {
case DialogType::User:
return td_->contacts_manager_->get_input_peer_user(dialog_id.get_user_id(), access_rights);
case DialogType::Chat:
return td_->contacts_manager_->get_input_peer_chat(dialog_id.get_chat_id(), access_rights);
case DialogType::Channel:
return td_->contacts_manager_->get_input_peer_channel(dialog_id.get_channel_id(), access_rights);
case DialogType::SecretChat:
return nullptr;
case DialogType::None:
return make_tl_object<telegram_api::inputPeerEmpty>();
default:
UNREACHABLE();
return nullptr;
}
}
tl_object_ptr<telegram_api::InputPeer> DialogManager::get_input_peer_force(DialogId dialog_id) {
switch (dialog_id.get_type()) {
case DialogType::User: {
UserId user_id = dialog_id.get_user_id();
return make_tl_object<telegram_api::inputPeerUser>(user_id.get(), 0);
}
case DialogType::Chat: {
ChatId chat_id = dialog_id.get_chat_id();
return make_tl_object<telegram_api::inputPeerChat>(chat_id.get());
}
case DialogType::Channel: {
ChannelId channel_id = dialog_id.get_channel_id();
return make_tl_object<telegram_api::inputPeerChannel>(channel_id.get(), 0);
}
case DialogType::SecretChat:
case DialogType::None:
return make_tl_object<telegram_api::inputPeerEmpty>();
default:
UNREACHABLE();
return nullptr;
}
}
vector<tl_object_ptr<telegram_api::InputPeer>> DialogManager::get_input_peers(const vector<DialogId> &dialog_ids,
AccessRights access_rights) const {
vector<tl_object_ptr<telegram_api::InputPeer>> input_peers;
input_peers.reserve(dialog_ids.size());
for (auto &dialog_id : dialog_ids) {
auto input_peer = get_input_peer(dialog_id, access_rights);
if (input_peer == nullptr) {
LOG(ERROR) << "Have no access to " << dialog_id;
continue;
}
input_peers.push_back(std::move(input_peer));
}
return input_peers;
}
tl_object_ptr<telegram_api::InputDialogPeer> DialogManager::get_input_dialog_peer(DialogId dialog_id,
AccessRights access_rights) const {
switch (dialog_id.get_type()) {
case DialogType::User:
case DialogType::Chat:
case DialogType::Channel:
case DialogType::None:
return make_tl_object<telegram_api::inputDialogPeer>(get_input_peer(dialog_id, access_rights));
case DialogType::SecretChat:
return nullptr;
default:
UNREACHABLE();
return nullptr;
}
}
vector<tl_object_ptr<telegram_api::InputDialogPeer>> DialogManager::get_input_dialog_peers(
const vector<DialogId> &dialog_ids, AccessRights access_rights) const {
vector<tl_object_ptr<telegram_api::InputDialogPeer>> input_dialog_peers;
input_dialog_peers.reserve(dialog_ids.size());
for (auto &dialog_id : dialog_ids) {
auto input_dialog_peer = get_input_dialog_peer(dialog_id, access_rights);
if (input_dialog_peer == nullptr) {
LOG(ERROR) << "Have no access to " << dialog_id;
continue;
}
input_dialog_peers.push_back(std::move(input_dialog_peer));
}
return input_dialog_peers;
}
tl_object_ptr<telegram_api::inputEncryptedChat> DialogManager::get_input_encrypted_chat(
DialogId dialog_id, AccessRights access_rights) const {
switch (dialog_id.get_type()) {
case DialogType::SecretChat: {
SecretChatId secret_chat_id = dialog_id.get_secret_chat_id();
return td_->contacts_manager_->get_input_encrypted_chat(secret_chat_id, access_rights);
}
case DialogType::User:
case DialogType::Chat:
case DialogType::Channel:
case DialogType::None:
default:
UNREACHABLE();
return nullptr;
}
}
bool DialogManager::have_input_peer(DialogId dialog_id, AccessRights access_rights) const {
switch (dialog_id.get_type()) {
case DialogType::User: {
UserId user_id = dialog_id.get_user_id();
return td_->contacts_manager_->have_input_peer_user(user_id, access_rights);
}
case DialogType::Chat: {
ChatId chat_id = dialog_id.get_chat_id();
return td_->contacts_manager_->have_input_peer_chat(chat_id, access_rights);
}
case DialogType::Channel: {
ChannelId channel_id = dialog_id.get_channel_id();
return td_->contacts_manager_->have_input_peer_channel(channel_id, access_rights);
}
case DialogType::SecretChat: {
SecretChatId secret_chat_id = dialog_id.get_secret_chat_id();
return td_->contacts_manager_->have_input_encrypted_peer(secret_chat_id, access_rights);
}
case DialogType::None:
return false;
default:
UNREACHABLE();
return false;
}
}
bool DialogManager::have_dialog_force(DialogId dialog_id, const char *source) const {
return td_->messages_manager_->have_dialog_force(dialog_id, source);
}
bool DialogManager::have_dialog_info(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User: {
UserId user_id = dialog_id.get_user_id();
return td_->contacts_manager_->have_user(user_id);
}
case DialogType::Chat: {
ChatId chat_id = dialog_id.get_chat_id();
return td_->contacts_manager_->have_chat(chat_id);
}
case DialogType::Channel: {
ChannelId channel_id = dialog_id.get_channel_id();
return td_->contacts_manager_->have_channel(channel_id);
}
case DialogType::SecretChat: {
SecretChatId secret_chat_id = dialog_id.get_secret_chat_id();
return td_->contacts_manager_->have_secret_chat(secret_chat_id);
}
case DialogType::None:
default:
return false;
}
}
bool DialogManager::have_dialog_info_force(DialogId dialog_id, const char *source) const {
switch (dialog_id.get_type()) {
case DialogType::User: {
UserId user_id = dialog_id.get_user_id();
return td_->contacts_manager_->have_user_force(user_id, source);
}
case DialogType::Chat: {
ChatId chat_id = dialog_id.get_chat_id();
return td_->contacts_manager_->have_chat_force(chat_id, source);
}
case DialogType::Channel: {
ChannelId channel_id = dialog_id.get_channel_id();
return td_->contacts_manager_->have_channel_force(channel_id, source);
}
case DialogType::SecretChat: {
SecretChatId secret_chat_id = dialog_id.get_secret_chat_id();
return td_->contacts_manager_->have_secret_chat_force(secret_chat_id, source);
}
case DialogType::None:
default:
return false;
}
}
void DialogManager::get_dialog_info_full(DialogId dialog_id, Promise<Unit> &&promise, const char *source) {
switch (dialog_id.get_type()) {
case DialogType::User:
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::load_user_full, dialog_id.get_user_id(), false,
std::move(promise), source);
return;
case DialogType::Chat:
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::load_chat_full, dialog_id.get_chat_id(), false,
std::move(promise), source);
return;
case DialogType::Channel:
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::load_channel_full, dialog_id.get_channel_id(),
false, std::move(promise), source);
return;
case DialogType::SecretChat:
return promise.set_value(Unit());
case DialogType::None:
default:
UNREACHABLE();
return promise.set_error(Status::Error(500, "Wrong chat type"));
}
}
void DialogManager::reload_dialog_info_full(DialogId dialog_id, const char *source) {
if (G()->close_flag()) {
return;
}
LOG(INFO) << "Reload full info about " << dialog_id << " from " << source;
switch (dialog_id.get_type()) {
case DialogType::User:
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::reload_user_full, dialog_id.get_user_id(),
Promise<Unit>(), source);
return;
case DialogType::Chat:
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::reload_chat_full, dialog_id.get_chat_id(),
Promise<Unit>(), source);
return;
case DialogType::Channel:
send_closure_later(td_->contacts_manager_actor_, &ContactsManager::reload_channel_full,
dialog_id.get_channel_id(), Promise<Unit>(), source);
return;
case DialogType::SecretChat:
return;
case DialogType::None:
default:
UNREACHABLE();
return;
}
}
td_api::object_ptr<td_api::ChatType> DialogManager::get_chat_type_object(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User:
return td_api::make_object<td_api::chatTypePrivate>(
td_->contacts_manager_->get_user_id_object(dialog_id.get_user_id(), "chatTypePrivate"));
case DialogType::Chat:
return td_api::make_object<td_api::chatTypeBasicGroup>(
td_->contacts_manager_->get_basic_group_id_object(dialog_id.get_chat_id(), "chatTypeBasicGroup"));
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
return td_api::make_object<td_api::chatTypeSupergroup>(
td_->contacts_manager_->get_supergroup_id_object(channel_id, "chatTypeSupergroup"),
!td_->contacts_manager_->is_megagroup_channel(channel_id));
}
case DialogType::SecretChat: {
auto secret_chat_id = dialog_id.get_secret_chat_id();
auto user_id = td_->contacts_manager_->get_secret_chat_user_id(secret_chat_id);
return td_api::make_object<td_api::chatTypeSecret>(
td_->contacts_manager_->get_secret_chat_id_object(secret_chat_id, "chatTypeSecret"),
td_->contacts_manager_->get_user_id_object(user_id, "chatTypeSecret"));
}
case DialogType::None:
default:
UNREACHABLE();
return nullptr;
}
}
NotificationSettingsScope DialogManager::get_dialog_notification_setting_scope(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User:
case DialogType::SecretChat:
return NotificationSettingsScope::Private;
case DialogType::Chat:
return NotificationSettingsScope::Group;
case DialogType::Channel:
return is_broadcast_channel(dialog_id) ? NotificationSettingsScope::Channel : NotificationSettingsScope::Group;
case DialogType::None:
default:
UNREACHABLE();
return NotificationSettingsScope::Private;
}
}
bool DialogManager::is_anonymous_administrator(DialogId dialog_id, string *author_signature) const {
CHECK(dialog_id.is_valid());
if (is_broadcast_channel(dialog_id)) {
return true;
}
if (td_->auth_manager_->is_bot()) {
return false;
}
if (dialog_id.get_type() != DialogType::Channel) {
return false;
}
auto status = td_->contacts_manager_->get_channel_status(dialog_id.get_channel_id());
if (!status.is_anonymous()) {
return false;
}
if (author_signature != nullptr) {
*author_signature = status.get_rank();
}
return true;
}
bool DialogManager::is_group_dialog(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::Chat:
return true;
case DialogType::Channel:
return td_->contacts_manager_->is_megagroup_channel(dialog_id.get_channel_id());
default:
return false;
}
}
bool DialogManager::is_forum_channel(DialogId dialog_id) const {
return dialog_id.get_type() == DialogType::Channel &&
td_->contacts_manager_->is_forum_channel(dialog_id.get_channel_id());
}
bool DialogManager::is_broadcast_channel(DialogId dialog_id) const {
if (dialog_id.get_type() != DialogType::Channel) {
return false;
}
return td_->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id());
}
bool DialogManager::on_get_dialog_error(DialogId dialog_id, const Status &status, const char *source) {
if (status.message() == CSlice("BOT_METHOD_INVALID")) {
LOG(ERROR) << "Receive BOT_METHOD_INVALID from " << source;
return true;
}
if (G()->is_expected_error(status)) {
return true;
}
if (status.message() == CSlice("SEND_AS_PEER_INVALID")) {
reload_dialog_info_full(dialog_id, "SEND_AS_PEER_INVALID");
return true;
}
if (status.message() == CSlice("QUOTE_TEXT_INVALID") || status.message() == CSlice("REPLY_MESSAGE_ID_INVALID")) {
return true;
}
switch (dialog_id.get_type()) {
case DialogType::User:
case DialogType::Chat:
case DialogType::SecretChat:
// to be implemented if necessary
break;
case DialogType::Channel:
return td_->contacts_manager_->on_get_channel_error(dialog_id.get_channel_id(), status, source);
case DialogType::None:
// to be implemented if necessary
break;
default:
UNREACHABLE();
}
return false;
}
string DialogManager::get_dialog_title(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User:
return td_->contacts_manager_->get_user_title(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_title(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_title(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->contacts_manager_->get_secret_chat_title(dialog_id.get_secret_chat_id());
case DialogType::None:
default:
UNREACHABLE();
return string();
}
}
const DialogPhoto *DialogManager::get_dialog_photo(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User:
return td_->contacts_manager_->get_user_dialog_photo(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_dialog_photo(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_dialog_photo(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->contacts_manager_->get_secret_chat_dialog_photo(dialog_id.get_secret_chat_id());
case DialogType::None:
default:
UNREACHABLE();
return nullptr;
}
}
int32 DialogManager::get_dialog_accent_color_id_object(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User:
return td_->contacts_manager_->get_user_accent_color_id_object(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_accent_color_id_object(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_accent_color_id_object(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->contacts_manager_->get_secret_chat_accent_color_id_object(dialog_id.get_secret_chat_id());
case DialogType::None:
default:
UNREACHABLE();
return 0;
}
}
CustomEmojiId DialogManager::get_dialog_background_custom_emoji_id(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User:
return td_->contacts_manager_->get_user_background_custom_emoji_id(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_background_custom_emoji_id(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_background_custom_emoji_id(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->contacts_manager_->get_secret_chat_background_custom_emoji_id(dialog_id.get_secret_chat_id());
case DialogType::None:
default:
UNREACHABLE();
return CustomEmojiId();
}
}
int32 DialogManager::get_dialog_profile_accent_color_id_object(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User:
return td_->contacts_manager_->get_user_profile_accent_color_id_object(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_profile_accent_color_id_object(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_profile_accent_color_id_object(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->contacts_manager_->get_secret_chat_profile_accent_color_id_object(dialog_id.get_secret_chat_id());
case DialogType::None:
default:
UNREACHABLE();
return 0;
}
}
CustomEmojiId DialogManager::get_dialog_profile_background_custom_emoji_id(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User:
return td_->contacts_manager_->get_user_profile_background_custom_emoji_id(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_profile_background_custom_emoji_id(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_profile_background_custom_emoji_id(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->contacts_manager_->get_secret_chat_profile_background_custom_emoji_id(dialog_id.get_secret_chat_id());
case DialogType::None:
default:
UNREACHABLE();
return CustomEmojiId();
}
}
RestrictedRights DialogManager::get_dialog_default_permissions(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User:
return td_->contacts_manager_->get_user_default_permissions(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_default_permissions(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_default_permissions(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->contacts_manager_->get_secret_chat_default_permissions(dialog_id.get_secret_chat_id());
case DialogType::None:
default:
UNREACHABLE();
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, ChannelType::Unknown);
}
}
td_api::object_ptr<td_api::emojiStatus> DialogManager::get_dialog_emoji_status_object(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User:
return td_->contacts_manager_->get_user_emoji_status_object(dialog_id.get_user_id());
case DialogType::Chat:
return td_->contacts_manager_->get_chat_emoji_status_object(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_emoji_status_object(dialog_id.get_channel_id());
case DialogType::SecretChat:
return td_->contacts_manager_->get_secret_chat_emoji_status_object(dialog_id.get_secret_chat_id());
case DialogType::None:
default:
UNREACHABLE();
return 0;
}
}
bool DialogManager::get_dialog_has_protected_content(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User:
return false;
case DialogType::Chat:
return td_->contacts_manager_->get_chat_has_protected_content(dialog_id.get_chat_id());
case DialogType::Channel:
return td_->contacts_manager_->get_channel_has_protected_content(dialog_id.get_channel_id());
case DialogType::SecretChat:
return false;
case DialogType::None:
default:
UNREACHABLE();
return true;
}
}
bool DialogManager::is_dialog_action_unneeded(DialogId dialog_id) const {
if (is_anonymous_administrator(dialog_id, nullptr)) {
return true;
}
auto dialog_type = dialog_id.get_type();
if (dialog_type == DialogType::User || dialog_type == DialogType::SecretChat) {
UserId user_id = dialog_type == DialogType::User
? dialog_id.get_user_id()
: td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
if (td_->contacts_manager_->is_user_deleted(user_id)) {
return true;
}
if (td_->contacts_manager_->is_user_bot(user_id) && !td_->contacts_manager_->is_user_support(user_id)) {
return true;
}
if (user_id == td_->contacts_manager_->get_my_id()) {
return true;
}
if (!td_->auth_manager_->is_bot()) {
if (td_->contacts_manager_->is_user_status_exact(user_id)) {
if (!td_->contacts_manager_->is_user_online(user_id, 30)) {
return true;
}
} else {
// return true;
}
}
}
return false;
}
void DialogManager::set_dialog_accent_color(DialogId dialog_id, AccentColorId accent_color_id,
CustomEmojiId background_custom_emoji_id, Promise<Unit> &&promise) {
if (!have_dialog_force(dialog_id, "set_dialog_accent_color")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
switch (dialog_id.get_type()) {
case DialogType::User:
if (dialog_id == get_my_dialog_id()) {
return td_->contacts_manager_->set_accent_color(accent_color_id, background_custom_emoji_id,
std::move(promise));
}
break;
case DialogType::Chat:
break;
case DialogType::Channel:
return td_->contacts_manager_->set_channel_accent_color(dialog_id.get_channel_id(), accent_color_id,
background_custom_emoji_id, std::move(promise));
case DialogType::SecretChat:
break;
case DialogType::None:
default:
UNREACHABLE();
}
promise.set_error(Status::Error(400, "Can't change accent color in the chat"));
}
void DialogManager::set_dialog_profile_accent_color(DialogId dialog_id, AccentColorId profile_accent_color_id,
CustomEmojiId profile_background_custom_emoji_id,
Promise<Unit> &&promise) {
if (!have_dialog_force(dialog_id, "set_dialog_profile_accent_color")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
switch (dialog_id.get_type()) {
case DialogType::User:
if (dialog_id == get_my_dialog_id()) {
return td_->contacts_manager_->set_profile_accent_color(profile_accent_color_id,
profile_background_custom_emoji_id, std::move(promise));
}
break;
case DialogType::Chat:
break;
case DialogType::Channel:
return td_->contacts_manager_->set_channel_profile_accent_color(
dialog_id.get_channel_id(), profile_accent_color_id, profile_background_custom_emoji_id, std::move(promise));
case DialogType::SecretChat:
break;
case DialogType::None:
default:
UNREACHABLE();
}
promise.set_error(Status::Error(400, "Can't change profile accent color in the chat"));
}
void DialogManager::set_dialog_emoji_status(DialogId dialog_id, const EmojiStatus &emoji_status,
Promise<Unit> &&promise) {
if (!have_dialog_force(dialog_id, "set_dialog_emoji_status")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
switch (dialog_id.get_type()) {
case DialogType::User:
if (dialog_id == get_my_dialog_id()) {
return td_->contacts_manager_->set_emoji_status(emoji_status, std::move(promise));
}
break;
case DialogType::Chat:
break;
case DialogType::Channel:
return td_->contacts_manager_->set_channel_emoji_status(dialog_id.get_channel_id(), emoji_status,
std::move(promise));
case DialogType::SecretChat:
break;
case DialogType::None:
default:
UNREACHABLE();
}
promise.set_error(Status::Error(400, "Can't change emoji status in the chat"));
}
void DialogManager::set_dialog_description(DialogId dialog_id, const string &description, Promise<Unit> &&promise) {
if (!have_dialog_force(dialog_id, "set_dialog_description")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
switch (dialog_id.get_type()) {
case DialogType::User:
return promise.set_error(Status::Error(400, "Can't change private chat description"));
case DialogType::Chat:
return td_->contacts_manager_->set_chat_description(dialog_id.get_chat_id(), description, std::move(promise));
case DialogType::Channel:
return td_->contacts_manager_->set_channel_description(dialog_id.get_channel_id(), description,
std::move(promise));
case DialogType::SecretChat:
return promise.set_error(Status::Error(400, "Can't change secret chat description"));
case DialogType::None:
default:
UNREACHABLE();
}
}
Status DialogManager::can_pin_messages(DialogId dialog_id) const {
switch (dialog_id.get_type()) {
case DialogType::User:
break;
case DialogType::Chat: {
auto chat_id = dialog_id.get_chat_id();
auto status = td_->contacts_manager_->get_chat_permissions(chat_id);
if (!status.can_pin_messages() ||
(td_->auth_manager_->is_bot() && !td_->contacts_manager_->is_appointed_chat_administrator(chat_id))) {
return Status::Error(400, "Not enough rights to manage pinned messages in the chat");
}
break;
}
case DialogType::Channel: {
auto status = td_->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id());
bool can_pin = is_broadcast_channel(dialog_id) ? status.can_edit_messages() : status.can_pin_messages();
if (!can_pin) {
return Status::Error(400, "Not enough rights to manage pinned messages in the chat");
}
break;
}
case DialogType::SecretChat:
return Status::Error(400, "Secret chats can't have pinned messages");
case DialogType::None:
default:
UNREACHABLE();
}
if (!have_input_peer(dialog_id, AccessRights::Write)) {
return Status::Error(400, "Not enough rights");
}
return Status::OK();
}
} // namespace td

View File

@ -6,9 +6,22 @@
//
#pragma once
#include "td/telegram/AccentColorId.h"
#include "td/telegram/AccessRights.h"
#include "td/telegram/CustomEmojiId.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogParticipant.h"
#include "td/telegram/EmojiStatus.h"
#include "td/telegram/NotificationSettingsScope.h"
#include "td/telegram/Photo.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/actor/actor.h"
#include "td/utils/common.h"
#include "td/utils/Promise.h"
#include "td/utils/Status.h"
namespace td {
@ -18,6 +31,82 @@ class DialogManager final : public Actor {
public:
DialogManager(Td *td, ActorShared<> parent);
DialogId get_my_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);
vector<tl_object_ptr<telegram_api::InputPeer>> get_input_peers(const vector<DialogId> &dialog_ids,
AccessRights access_rights) const;
tl_object_ptr<telegram_api::InputDialogPeer> get_input_dialog_peer(DialogId dialog_id,
AccessRights access_rights) const;
vector<tl_object_ptr<telegram_api::InputDialogPeer>> get_input_dialog_peers(const vector<DialogId> &dialog_ids,
AccessRights access_rights) const;
tl_object_ptr<telegram_api::inputEncryptedChat> get_input_encrypted_chat(DialogId dialog_id,
AccessRights access_rights) const;
bool have_input_peer(DialogId dialog_id, AccessRights access_rights) const;
bool have_dialog_force(DialogId dialog_id, const char *source) const;
bool have_dialog_info(DialogId dialog_id) const;
bool have_dialog_info_force(DialogId dialog_id, const char *source) const;
void get_dialog_info_full(DialogId dialog_id, Promise<Unit> &&promise, const char *source);
void reload_dialog_info_full(DialogId dialog_id, const char *source);
td_api::object_ptr<td_api::ChatType> get_chat_type_object(DialogId dialog_id) const;
NotificationSettingsScope get_dialog_notification_setting_scope(DialogId dialog_id) const;
bool is_anonymous_administrator(DialogId dialog_id, string *author_signature) const;
bool is_group_dialog(DialogId dialog_id) const;
bool is_forum_channel(DialogId dialog_id) const;
bool is_broadcast_channel(DialogId dialog_id) const;
bool on_get_dialog_error(DialogId dialog_id, const Status &status, const char *source);
string get_dialog_title(DialogId dialog_id) const;
const DialogPhoto *get_dialog_photo(DialogId dialog_id) const;
int32 get_dialog_accent_color_id_object(DialogId dialog_id) const;
CustomEmojiId get_dialog_background_custom_emoji_id(DialogId dialog_id) const;
int32 get_dialog_profile_accent_color_id_object(DialogId dialog_id) const;
CustomEmojiId get_dialog_profile_background_custom_emoji_id(DialogId dialog_id) const;
RestrictedRights get_dialog_default_permissions(DialogId dialog_id) const;
td_api::object_ptr<td_api::emojiStatus> get_dialog_emoji_status_object(DialogId dialog_id) const;
bool get_dialog_has_protected_content(DialogId dialog_id) const;
bool is_dialog_action_unneeded(DialogId dialog_id) const;
void set_dialog_accent_color(DialogId dialog_id, AccentColorId accent_color_id,
CustomEmojiId background_custom_emoji_id, Promise<Unit> &&promise);
void set_dialog_profile_accent_color(DialogId dialog_id, AccentColorId profile_accent_color_id,
CustomEmojiId profile_background_custom_emoji_id, Promise<Unit> &&promise);
void set_dialog_emoji_status(DialogId dialog_id, const EmojiStatus &emoji_status, Promise<Unit> &&promise);
void set_dialog_description(DialogId dialog_id, const string &description, Promise<Unit> &&promise);
Status can_pin_messages(DialogId dialog_id) const;
private:
void tear_down() final;

View File

@ -8,6 +8,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/MessagesManager.h"
@ -32,7 +33,7 @@ class SaveDraftMessageQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, const unique_ptr<DraftMessage> &draft_message) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
LOG(INFO) << "Can't update draft message because have no write access to " << dialog_id;
return on_error(Status::Error(400, "Can't save draft message"));
@ -90,7 +91,7 @@ class SaveDraftMessageQuery final : public Td::ResultHandler {
// with the error "TOPIC_CLOSED", but the draft will be kept locally
return promise_.set_value(Unit());
}
if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SaveDraftMessageQuery")) {
if (!td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "SaveDraftMessageQuery")) {
LOG(ERROR) << "Receive error for SaveDraftMessageQuery: " << status;
}
promise_.set_error(std::move(status));

View File

@ -6,6 +6,7 @@
//
#include "td/telegram/ForumTopicInfo.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/MessageSender.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/ServerMessageId.h"
@ -29,7 +30,7 @@ ForumTopicInfo::ForumTopicInfo(Td *td, const tl_object_ptr<telegram_api::ForumTo
creation_date_ = forum_topic->date_;
creator_dialog_id_ = DialogId(forum_topic->from_id_);
if (creator_dialog_id_.is_valid() && creator_dialog_id_.get_type() != DialogType::User &&
td->messages_manager_->have_dialog_info_force(creator_dialog_id_, "ForumTopicInfo")) {
td->dialog_manager_->have_dialog_info_force(creator_dialog_id_, "ForumTopicInfo")) {
td->messages_manager_->force_create_dialog(creator_dialog_id_, "ForumTopicInfo", true);
}
is_outgoing_ = forum_topic->my_;

View File

@ -11,6 +11,7 @@
#include "td/telegram/ChannelId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/CustomEmojiId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/ForumTopic.h"
#include "td/telegram/ForumTopic.hpp"
#include "td/telegram/ForumTopicIcon.h"
@ -63,7 +64,7 @@ class CreateForumTopicQuery final : public Td::ResultHandler {
}
tl_object_ptr<telegram_api::InputPeer> as_input_peer;
if (as_dialog_id.is_valid()) {
as_input_peer = td_->messages_manager_->get_input_peer(as_dialog_id, AccessRights::Write);
as_input_peer = td_->dialog_manager_->get_input_peer(as_dialog_id, AccessRights::Write);
if (as_input_peer != nullptr) {
flags |= telegram_api::channels_createForumTopic::SEND_AS_MASK;
creator_dialog_id_ = as_dialog_id;
@ -422,7 +423,7 @@ class ReadForumTopicQuery final : public Td::ResultHandler {
public:
void send(DialogId dialog_id, MessageId top_thread_message_id, MessageId max_message_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
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"));
}
@ -441,7 +442,7 @@ class ReadForumTopicQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReadForumTopicQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "ReadForumTopicQuery");
}
};

View File

@ -11,6 +11,7 @@
#include "td/telegram/ChainId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/InlineQueriesManager.h"
#include "td/telegram/MessageId.h"
@ -47,7 +48,7 @@ class SetGameScoreQuery final : public Td::ResultHandler {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Edit);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Edit);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -72,7 +73,7 @@ class SetGameScoreQuery final : public Td::ResultHandler {
void on_error(Status status) final {
LOG(INFO) << "Receive error for SetGameScoreQuery: " << status;
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetGameScoreQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "SetGameScoreQuery");
promise_.set_error(std::move(status));
}
};
@ -133,7 +134,7 @@ class GetGameHighScoresQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, MessageId message_id, tl_object_ptr<telegram_api::InputUser> input_user) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
CHECK(input_peer != nullptr);
CHECK(input_user != nullptr);
@ -151,7 +152,7 @@ class GetGameHighScoresQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGameHighScoresQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetGameHighScoresQuery");
promise_.set_error(std::move(status));
}
};
@ -207,7 +208,7 @@ void GameManager::set_game_score(MessageFullId message_full_id, bool edit_messag
}
auto dialog_id = message_full_id.get_dialog_id();
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Edit)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Edit)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
@ -257,7 +258,7 @@ void GameManager::get_game_high_scores(MessageFullId message_full_id, UserId use
}
auto dialog_id = message_full_id.get_dialog_id();
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
auto message_id = message_full_id.get_message_id();

View File

@ -10,6 +10,7 @@
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/misc.h"
@ -93,12 +94,12 @@ GiveawayParameters::get_input_store_payment_premium_giveaway(Td *td, const strin
random_id = Random::secure_int64();
} while (random_id == 0);
auto boost_input_peer = td->messages_manager_->get_input_peer(DialogId(boosted_channel_id_), AccessRights::Write);
auto boost_input_peer = td->dialog_manager_->get_input_peer(DialogId(boosted_channel_id_), AccessRights::Write);
CHECK(boost_input_peer != nullptr);
vector<telegram_api::object_ptr<telegram_api::InputPeer>> additional_input_peers;
for (auto additional_channel_id : additional_channel_ids_) {
auto input_peer = td->messages_manager_->get_input_peer(DialogId(additional_channel_id), AccessRights::Write);
auto input_peer = td->dialog_manager_->get_input_peer(DialogId(additional_channel_id), AccessRights::Write);
CHECK(input_peer != nullptr);
additional_input_peers.push_back(std::move(input_peer));
}

View File

@ -42,6 +42,7 @@ class ConfigManager;
class ConnectionCreator;
class ContactsManager;
class DialogFilterManager;
class DialogManager;
class DownloadManager;
class FileManager;
class FileReferenceManager;
@ -251,6 +252,13 @@ class Global final : public ActorContext {
dialog_filter_manager_ = std::move(dialog_filter_manager);
}
ActorId<DialogManager> dialog_manager() const {
return dialog_manager_;
}
void set_dialog_manager(ActorId<DialogManager> dialog_manager) {
dialog_manager_ = std::move(dialog_manager);
}
ActorId<DownloadManager> download_manager() const {
return download_manager_;
}
@ -547,6 +555,7 @@ class Global final : public ActorContext {
ActorId<ConfigManager> config_manager_;
ActorId<ContactsManager> contacts_manager_;
ActorId<DialogFilterManager> dialog_filter_manager_;
ActorId<DialogManager> dialog_manager_;
ActorId<DownloadManager> download_manager_;
ActorId<FileManager> file_manager_;
ActorId<FileReferenceManager> file_reference_manager_;

View File

@ -10,6 +10,7 @@
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogAction.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/DialogParticipantFilter.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessageId.h"
@ -123,7 +124,7 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler {
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(G()->net_query_creator().create(telegram_api::phone_getGroupCallJoinAs(std::move(input_peer))));
@ -145,7 +146,7 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallJoinAsQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallJoinAsQuery");
promise_.set_error(std::move(status));
}
};
@ -158,10 +159,10 @@ class SaveDefaultGroupCallJoinAsQuery final : public Td::ResultHandler {
}
void send(DialogId dialog_id, DialogId as_dialog_id) {
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
CHECK(input_peer != nullptr);
auto as_input_peer = td_->messages_manager_->get_input_peer(as_dialog_id, AccessRights::Read);
auto as_input_peer = td_->dialog_manager_->get_input_peer(as_dialog_id, AccessRights::Read);
CHECK(as_input_peer != nullptr);
send_query(G()->net_query_creator().create(
@ -181,7 +182,7 @@ class SaveDefaultGroupCallJoinAsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
// td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallJoinAsQuery");
// td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallJoinAsQuery");
promise_.set_error(std::move(status));
}
};
@ -197,7 +198,7 @@ class CreateGroupCallQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, const string &title, int32 start_date, bool is_rtmp_stream) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
CHECK(input_peer != nullptr);
int32 flags = 0;
@ -243,7 +244,7 @@ class CreateGroupCallQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "CreateGroupCallQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "CreateGroupCallQuery");
promise_.set_error(std::move(status));
}
};
@ -260,7 +261,7 @@ class GetGroupCallRtmpStreamUrlGroupCallQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, bool revoke) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(
@ -278,7 +279,7 @@ class GetGroupCallRtmpStreamUrlGroupCallQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallRtmpStreamUrlGroupCallQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallRtmpStreamUrlGroupCallQuery");
promise_.set_error(std::move(status));
}
};
@ -430,7 +431,7 @@ class JoinGroupCallQuery final : public Td::ResultHandler {
tl_object_ptr<telegram_api::InputPeer> join_as_input_peer;
if (as_dialog_id.is_valid()) {
join_as_input_peer = td_->messages_manager_->get_input_peer(as_dialog_id, AccessRights::Read);
join_as_input_peer = td_->dialog_manager_->get_input_peer(as_dialog_id, AccessRights::Read);
} else {
join_as_input_peer = make_tl_object<telegram_api::inputPeerSelf>();
}
@ -748,7 +749,7 @@ class EditGroupCallParticipantQuery final : public Td::ResultHandler {
int32 volume_level, bool set_raise_hand, bool raise_hand, bool set_video_is_stopped, bool video_is_stopped,
bool set_video_is_paused, bool video_is_paused, bool set_presentation_is_paused,
bool presentation_is_paused) {
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Know);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Know);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -1225,7 +1226,7 @@ Status GroupCallManager::can_join_group_calls(DialogId dialog_id) const {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_group_call_join_as")) {
return Status::Error(400, "Chat not found");
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return Status::Error(400, "Can't access chat");
}
switch (dialog_id.get_type()) {
@ -1319,7 +1320,7 @@ void GroupCallManager::set_group_call_default_join_as(DialogId dialog_id, Dialog
default:
return promise.set_error(Status::Error(400, "Invalid default participant identifier specified"));
}
if (!td_->messages_manager_->have_input_peer(as_dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(as_dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access specified default participant chat"));
}
@ -1335,7 +1336,7 @@ void GroupCallManager::create_voice_chat(DialogId dialog_id, string title, int32
if (!td_->messages_manager_->have_dialog_force(dialog_id, "create_voice_chat")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access chat"));
}
@ -1364,7 +1365,7 @@ void GroupCallManager::get_voice_chat_rtmp_stream_url(DialogId dialog_id, bool r
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_voice_chat_rtmp_stream_url")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access chat"));
}
@ -1808,7 +1809,7 @@ void GroupCallManager::on_update_group_call_participants(
}
if (!missing_participants.empty()) {
LOG(INFO) << "Can't apply min updates about " << missing_participants << " in " << input_group_call_id;
auto input_peers = transform(missing_participants, &MessagesManager::get_input_peer_force);
auto input_peers = transform(missing_participants, &DialogManager::get_input_peer_force);
auto query_promise =
PromiseCreator::lambda([actor_id = actor_id(this), input_group_call_id,
participants = std::move(participants), version](Result<Unit> &&result) mutable {
@ -2647,7 +2648,7 @@ void GroupCallManager::join_group_call(GroupCallId group_call_id, DialogId as_di
return promise.set_error(Status::Error(400, "Join as chat not found"));
}
}
if (!td_->messages_manager_->have_input_peer(as_dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(as_dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the join as participant"));
}
if (dialog_type == DialogType::SecretChat) {
@ -2954,7 +2955,7 @@ void GroupCallManager::finish_join_group_call(InputGroupCallId input_group_call_
if (group_call != nullptr && group_call->dialog_id.is_valid()) {
update_group_call_dialog(group_call, "finish_join_group_call", false);
td_->messages_manager_->reload_dialog_info_full(group_call->dialog_id, "finish_join_group_call");
td_->dialog_manager_->reload_dialog_info_full(group_call->dialog_id, "finish_join_group_call");
}
}
@ -4122,7 +4123,7 @@ void GroupCallManager::on_group_call_left_impl(GroupCall *group_call, bool need_
group_call->need_rejoin = need_rejoin && !group_call->is_being_left;
if (group_call->need_rejoin && group_call->dialog_id.is_valid()) {
auto dialog_id = group_call->dialog_id;
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read) ||
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read) ||
(dialog_id.get_type() == DialogType::Chat &&
!td_->contacts_manager_->get_chat_status(dialog_id.get_chat_id()).is_member())) {
group_call->need_rejoin = false;
@ -4546,7 +4547,7 @@ void GroupCallManager::on_user_speaking_in_group_call(GroupCallId group_call_id,
return;
}
if (!td_->messages_manager_->have_dialog_info_force(dialog_id, "on_user_speaking_in_group_call") ||
if (!td_->dialog_manager_->have_dialog_info_force(dialog_id, "on_user_speaking_in_group_call") ||
(!is_recursive && need_group_call_participants(input_group_call_id, group_call) &&
get_group_call_participant(input_group_call_id, dialog_id) == nullptr)) {
if (is_recursive) {
@ -4560,7 +4561,7 @@ void GroupCallManager::on_user_speaking_in_group_call(GroupCallId group_call_id,
}
});
vector<tl_object_ptr<telegram_api::InputPeer>> input_peers;
input_peers.push_back(MessagesManager::get_input_peer_force(dialog_id));
input_peers.push_back(DialogManager::get_input_peer_force(dialog_id));
td_->create_handler<GetGroupCallParticipantQuery>(std::move(query_promise))
->send(input_group_call_id, std::move(input_peers), {});
}

View File

@ -12,6 +12,7 @@
#include "td/telegram/AuthManager.h"
#include "td/telegram/Contact.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/files/FileManager.h"
@ -1032,7 +1033,7 @@ uint64 InlineQueriesManager::send_inline_query(UserId bot_user_id, DialogId dial
return 0;
}
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
input_peer = make_tl_object<telegram_api::inputPeerEmpty>();
}

View File

@ -13,6 +13,7 @@
#include "td/telegram/ConfigManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/DialogParticipant.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessageEntity.h"
@ -854,7 +855,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler {
tl_object_ptr<telegram_api::InputPeer> input_peer;
if (message_full_id.get_dialog_id().is_valid()) {
dialog_id_ = message_full_id.get_dialog_id();
input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
flags |= telegram_api::messages_requestUrlAuth::PEER_MASK;
} else {
@ -899,7 +900,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler {
void on_error(Status status) final {
if (!dialog_id_.is_valid() ||
!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "RequestUrlAuthQuery")) {
!td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "RequestUrlAuthQuery")) {
LOG(INFO) << "Receive error for RequestUrlAuthQuery: " << status;
}
promise_.set_value(td_api::make_object<td_api::loginUrlInfoOpen>(url_, false));
@ -921,7 +922,7 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler {
tl_object_ptr<telegram_api::InputPeer> input_peer;
if (message_full_id.get_dialog_id().is_valid()) {
dialog_id_ = message_full_id.get_dialog_id();
input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
flags |= telegram_api::messages_acceptUrlAuth::PEER_MASK;
} else {
@ -960,7 +961,7 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler {
void on_error(Status status) final {
if (!dialog_id_.is_valid() ||
!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "AcceptUrlAuthQuery")) {
!td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "AcceptUrlAuthQuery")) {
LOG(INFO) << "Receive error for AcceptUrlAuthQuery: " << status;
}
promise_.set_error(std::move(status));

View File

@ -22,6 +22,7 @@
#include "td/telegram/CustomEmojiId.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogAction.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/DialogParticipant.h"
#include "td/telegram/Dimensions.h"
#include "td/telegram/Document.h"
@ -2795,7 +2796,7 @@ static Result<InputMessageContent> create_input_message_content(
if (!story_id.is_server()) {
return Status::Error(400, "Story can't be forwarded");
}
if (td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read) == nullptr) {
if (td->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read) == nullptr) {
return Status::Error(400, "Can't access the story");
}
content = make_unique<MessageStory>(story_full_id, false);
@ -2946,7 +2947,7 @@ bool can_have_input_media(const Td *td, const MessageContent *content, bool is_s
case MessageContentType::Story: {
auto story_full_id = static_cast<const MessageStory *>(content)->story_full_id;
auto dialog_id = story_full_id.get_dialog_id();
return td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read) != nullptr;
return td->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read) != nullptr;
}
case MessageContentType::Giveaway:
case MessageContentType::GiveawayWinners:

View File

@ -10,6 +10,7 @@
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/InputDialogId.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/misc.h"
@ -53,7 +54,7 @@ MessageInputReplyTo::MessageInputReplyTo(Td *td,
DialogId dialog_id;
if (reply_to->reply_to_peer_id_ != nullptr) {
dialog_id = InputDialogId(reply_to->reply_to_peer_id_).get_dialog_id();
if (!dialog_id.is_valid() || !td->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!dialog_id.is_valid() || !td->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return;
}
td->messages_manager_->force_create_dialog(dialog_id, "inputReplyToMessage");
@ -116,7 +117,7 @@ telegram_api::object_ptr<telegram_api::InputReplyTo> MessageInputReplyTo::get_in
}
telegram_api::object_ptr<telegram_api::InputPeer> input_peer;
if (dialog_id_ != DialogId()) {
input_peer = td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
input_peer = td->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
if (input_peer == nullptr) {
LOG(INFO) << "Failed to get input peer for " << dialog_id_;
return nullptr;

View File

@ -9,6 +9,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessageSender.h"
#include "td/telegram/MessagesManager.h"
@ -49,7 +50,7 @@ class GetMessagesReactionsQuery final : public Td::ResultHandler {
dialog_id_ = dialog_id;
message_ids_ = std::move(message_ids);
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(
@ -89,7 +90,7 @@ class GetMessagesReactionsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetMessagesReactionsQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetMessagesReactionsQuery");
td_->messages_manager_->try_reload_message_reactions(dialog_id_, true);
}
};
@ -105,7 +106,7 @@ class SendReactionQuery final : public Td::ResultHandler {
void send(MessageFullId message_full_id, vector<ReactionType> reaction_types, bool is_big, bool add_to_recent) {
dialog_id_ = message_full_id.get_dialog_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -145,7 +146,7 @@ class SendReactionQuery final : public Td::ResultHandler {
if (status.message() == "MESSAGE_NOT_MODIFIED") {
return promise_.set_value(Unit());
}
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendReactionQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "SendReactionQuery");
promise_.set_error(std::move(status));
}
};
@ -168,7 +169,7 @@ class GetMessageReactionsListQuery final : public Td::ResultHandler {
reaction_type_ = std::move(reaction_type);
offset_ = std::move(offset);
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -239,7 +240,7 @@ class GetMessageReactionsListQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetMessageReactionsListQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetMessageReactionsListQuery");
promise_.set_error(std::move(status));
}
};
@ -255,10 +256,10 @@ class ReportReactionQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, MessageId message_id, DialogId chooser_dialog_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
auto chooser_input_peer = td_->messages_manager_->get_input_peer(chooser_dialog_id, AccessRights::Know);
auto chooser_input_peer = td_->dialog_manager_->get_input_peer(chooser_dialog_id, AccessRights::Know);
if (chooser_input_peer == nullptr) {
return promise_.set_error(Status::Error(400, "Reaction sender is not accessible"));
}
@ -277,7 +278,7 @@ class ReportReactionQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReportReactionQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "ReportReactionQuery");
promise_.set_error(std::move(status));
}
};
@ -510,7 +511,7 @@ unique_ptr<MessageReactions> MessageReactions::get_message_reactions(
LOG(ERROR) << "Receive duplicate " << dialog_id << " as a recent chooser for " << reaction_type;
continue;
}
if (!td->messages_manager_->have_dialog_info(dialog_id)) {
if (!td->dialog_manager_->have_dialog_info(dialog_id)) {
auto dialog_type = dialog_id.get_type();
if (dialog_type == DialogType::User) {
auto user_id = dialog_id.get_user_id();
@ -860,7 +861,7 @@ StringBuilder &operator<<(StringBuilder &string_builder, const unique_ptr<Messag
}
void reload_message_reactions(Td *td, DialogId dialog_id, vector<MessageId> &&message_ids) {
if (!td->messages_manager_->have_input_peer(dialog_id, AccessRights::Read) ||
if (!td->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read) ||
dialog_id.get_type() == DialogType::SecretChat || message_ids.empty()) {
create_actor<SleepActor>(
"RetryReloadMessageReactionsActor", 0.2,
@ -928,7 +929,7 @@ void report_message_reactions(Td *td, MessageFullId message_full_id, DialogId ch
if (!td->messages_manager_->have_dialog_force(dialog_id, "send_callback_query")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
if (dialog_id.get_type() == DialogType::SecretChat) {
@ -946,7 +947,7 @@ void report_message_reactions(Td *td, MessageFullId message_full_id, DialogId ch
return promise.set_error(Status::Error(400, "Message reactions can't be reported"));
}
if (!td->messages_manager_->have_input_peer(chooser_dialog_id, AccessRights::Know)) {
if (!td->dialog_manager_->have_input_peer(chooser_dialog_id, AccessRights::Know)) {
return promise.set_error(Status::Error(400, "Reaction sender not found"));
}

View File

@ -7,6 +7,7 @@
#include "td/telegram/MessageReplyInfo.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/MessageSender.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/ServerMessageId.h"
@ -55,7 +56,7 @@ MessageReplyInfo::MessageReplyInfo(Td *td, tl_object_ptr<telegram_api::messageRe
LOG(ERROR) << "Receive duplicate " << dialog_id << " as a recent replier";
continue;
}
if (!td->messages_manager_->have_dialog_info(dialog_id)) {
if (!td->dialog_manager_->have_dialog_info(dialog_id)) {
auto dialog_type = dialog_id.get_type();
if (dialog_type == DialogType::User) {
auto replier_user_id = dialog_id.get_user_id();
@ -185,7 +186,7 @@ bool MessageReplyInfo::add_reply(DialogId replier_dialog_id, MessageId reply_mes
bool MessageReplyInfo::need_reget(const Td *td) const {
for (auto &dialog_id : recent_replier_dialog_ids_) {
if (dialog_id.get_type() != DialogType::User && !td->messages_manager_->have_dialog_info(dialog_id)) {
if (dialog_id.get_type() != DialogType::User && !td->dialog_manager_->have_dialog_info(dialog_id)) {
if (dialog_id.get_type() == DialogType::Channel &&
td->contacts_manager_->have_min_channel(dialog_id.get_channel_id())) {
return false;

View File

@ -8,6 +8,7 @@
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h"
@ -70,7 +71,7 @@ td_api::object_ptr<td_api::MessageSender> get_min_message_sender_object(Td *td,
}
} else {
if (!td->messages_manager_->have_dialog(dialog_id) &&
(td->messages_manager_->have_dialog_info(dialog_id) ||
(td->dialog_manager_->have_dialog_info(dialog_id) ||
(dialog_type == DialogType::Channel && td->contacts_manager_->have_min_channel(dialog_id.get_channel_id())))) {
LOG(INFO) << "Force creation of " << dialog_id;
td->messages_manager_->force_create_dialog(dialog_id, source, true);
@ -100,7 +101,7 @@ vector<DialogId> get_message_sender_dialog_ids(Td *td,
continue;
}
} else {
if (!td->messages_manager_->have_dialog_info(dialog_id)) {
if (!td->dialog_manager_->have_dialog_info(dialog_id)) {
continue;
}
td->messages_manager_->force_create_dialog(dialog_id, "get_message_sender_dialog_ids");

File diff suppressed because it is too large Load Diff

View File

@ -151,24 +151,6 @@ class MessagesManager final : public Actor {
static int32 get_message_date(const tl_object_ptr<telegram_api::Message> &message_ptr);
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);
vector<tl_object_ptr<telegram_api::InputPeer>> get_input_peers(const vector<DialogId> &dialog_ids,
AccessRights access_rights) const;
tl_object_ptr<telegram_api::InputDialogPeer> get_input_dialog_peer(DialogId dialog_id,
AccessRights access_rights) const;
vector<tl_object_ptr<telegram_api::InputDialogPeer>> get_input_dialog_peers(const vector<DialogId> &dialog_ids,
AccessRights access_rights) const;
tl_object_ptr<telegram_api::inputEncryptedChat> get_input_encrypted_chat(DialogId dialog_id,
AccessRights access_rights) const;
bool have_input_peer(DialogId dialog_id, AccessRights access_rights) const;
vector<DialogId> get_peers_dialog_ids(vector<tl_object_ptr<telegram_api::Peer>> &&peers,
bool expect_no_access = false);
@ -561,22 +543,12 @@ class MessagesManager final : public Actor {
void set_dialog_title(DialogId dialog_id, const string &title, Promise<Unit> &&promise);
void set_dialog_accent_color(DialogId dialog_id, AccentColorId accent_color_id,
CustomEmojiId background_custom_emoji_id, Promise<Unit> &&promise);
void set_dialog_profile_accent_color(DialogId dialog_id, AccentColorId profile_accent_color_id,
CustomEmojiId profile_background_custom_emoji_id, Promise<Unit> &&promise);
void set_dialog_description(DialogId dialog_id, const string &description, Promise<Unit> &&promise);
void set_active_reactions(vector<ReactionType> active_reaction_types);
void set_dialog_available_reactions(DialogId dialog_id,
td_api::object_ptr<td_api::ChatAvailableReactions> &&available_reactions_ptr,
Promise<Unit> &&promise);
void set_dialog_emoji_status(DialogId dialog_id, const EmojiStatus &emoji_status, Promise<Unit> &&promise);
void set_dialog_permissions(DialogId dialog_id, const td_api::object_ptr<td_api::chatPermissions> &permissions,
Promise<Unit> &&promise);
@ -589,18 +561,9 @@ class MessagesManager final : public Actor {
void unpin_all_dialog_messages(DialogId dialog_id, MessageId top_thread_message_id, Promise<Unit> &&promise);
void get_dialog_info_full(DialogId dialog_id, Promise<Unit> &&promise, const char *source);
string get_dialog_title(DialogId dialog_id) const;
bool have_dialog(DialogId dialog_id) const;
bool have_dialog_force(DialogId dialog_id, const char *source);
bool have_dialog_info(DialogId dialog_id) const;
bool have_dialog_info_force(DialogId dialog_id, const char *source) const;
void reload_dialog_info_full(DialogId dialog_id, const char *source);
void reload_dialog_notification_settings(DialogId dialog_id, Promise<Unit> &&promise, const char *source);
void on_dialog_info_full_invalidated(DialogId dialog_id);
@ -945,8 +908,6 @@ class MessagesManager final : public Actor {
void after_get_difference();
bool on_get_dialog_error(DialogId dialog_id, const Status &status, const char *source);
bool on_get_message_error(DialogId dialog_id, MessageId message_id, const Status &status, const char *source);
void on_send_message_get_quick_ack(int64 random_id);
@ -1770,8 +1731,6 @@ class MessagesManager final : public Actor {
void close_dialog(Dialog *d);
DialogId get_my_dialog_id() const;
void on_resolve_secret_chat_message_via_bot_username(const string &via_bot_username, MessageInfo *message_info_ptr,
Promise<Unit> &&promise);
@ -1819,8 +1778,6 @@ class MessagesManager final : public Actor {
Status can_use_top_thread_message_id(Dialog *d, MessageId top_thread_message_id,
const MessageInputReplyTo &input_reply_to);
bool is_anonymous_administrator(DialogId dialog_id, string *author_signature) const;
int64 generate_new_random_id(const Dialog *d);
unique_ptr<Message> create_message_to_send(Dialog *d, MessageId top_thread_message_id,
@ -1845,8 +1802,6 @@ class MessagesManager final : public Actor {
bool can_report_dialog(DialogId dialog_id) const;
Status can_pin_messages(DialogId dialog_id) const;
static Status can_get_media_timestamp_link(DialogId dialog_id, const Message *m);
bool can_report_message_reactions(DialogId dialog_id, const Message *m) const;
@ -2714,8 +2669,6 @@ class MessagesManager final : public Actor {
void queue_message_reactions_reload(DialogId dialog_id, const vector<MessageId> &message_ids);
bool is_dialog_action_unneeded(DialogId dialog_id) const;
void on_send_dialog_action_timeout(DialogId dialog_id);
void on_active_dialog_action_timeout(DialogId dialog_id);
@ -2746,8 +2699,6 @@ class MessagesManager final : public Actor {
void fix_dialog_action_bar(const Dialog *d, DialogActionBar *action_bar);
td_api::object_ptr<td_api::ChatType> get_chat_type_object(DialogId dialog_id) const;
td_api::object_ptr<td_api::ChatActionBar> get_chat_action_bar_object(const Dialog *d) const;
td_api::object_ptr<td_api::chatBackground> get_chat_background_object(const Dialog *d) const;
@ -2853,8 +2804,6 @@ class MessagesManager final : public Actor {
int64 get_dialog_notification_ringtone_id(DialogId dialog_id, const Dialog *d) const;
NotificationSettingsScope get_dialog_notification_setting_scope(DialogId dialog_id) const;
DialogNotificationSettings *get_dialog_notification_settings(DialogId dialog_id, bool force);
vector<FileId> get_message_file_ids(const Message *m) const;
@ -2993,22 +2942,6 @@ class MessagesManager final : public Actor {
Result<unique_ptr<ReplyMarkup>> get_dialog_reply_markup(
DialogId dialog_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr) const TD_WARN_UNUSED_RESULT;
const DialogPhoto *get_dialog_photo(DialogId dialog_id) const;
int32 get_dialog_accent_color_id_object(DialogId dialog_id) const;
CustomEmojiId get_dialog_background_custom_emoji_id(DialogId dialog_id) const;
int32 get_dialog_profile_accent_color_id_object(DialogId dialog_id) const;
CustomEmojiId get_dialog_profile_background_custom_emoji_id(DialogId dialog_id) const;
RestrictedRights get_dialog_default_permissions(DialogId dialog_id) const;
td_api::object_ptr<td_api::emojiStatus> get_dialog_emoji_status_object(DialogId dialog_id) const;
bool get_dialog_has_protected_content(DialogId dialog_id) const;
bool get_dialog_view_as_topics(const Dialog *d) const;
bool get_dialog_has_scheduled_messages(const Dialog *d) const;
@ -3296,12 +3229,6 @@ class MessagesManager final : public Actor {
void suffix_load_till_date(Dialog *d, int32 date, Promise<Unit> promise);
void suffix_load_till_message_id(Dialog *d, MessageId message_id, Promise<Unit> promise);
bool is_group_dialog(DialogId dialog_id) const;
bool is_forum_channel(DialogId dialog_id) const;
bool is_broadcast_channel(DialogId dialog_id) const;
bool is_deleted_secret_chat(const Dialog *d) const;
static int32 get_message_schedule_date(const Message *m);

View File

@ -11,6 +11,7 @@
#include "td/telegram/AudiosManager.hpp"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/FileReferenceManager.h"
@ -215,7 +216,7 @@ class GetDialogNotifySettingsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetDialogNotifySettingsQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetDialogNotifySettingsQuery");
td_->notification_settings_manager_->on_get_dialog_notification_settings_query_finished(
dialog_id_, top_thread_message_id_, std::move(status));
}
@ -411,7 +412,7 @@ class UpdateDialogNotifySettingsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "UpdateDialogNotifySettingsQuery")) {
if (!td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "UpdateDialogNotifySettingsQuery")) {
LOG(INFO) << "Receive error for set chat notification settings: " << status;
}
@ -665,7 +666,7 @@ tl_object_ptr<telegram_api::InputNotifyPeer> NotificationSettingsManager::get_in
if (!td_->messages_manager_->have_dialog(dialog_id)) {
return nullptr;
}
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
return nullptr;
}
@ -1407,7 +1408,7 @@ void NotificationSettingsManager::send_get_dialog_notification_settings_query(Di
LOG(WARNING) << "Can't get notification settings for " << dialog_id;
return promise.set_error(Status::Error(500, "Wrong getDialogNotificationSettings query"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
LOG(WARNING) << "Have no access to " << dialog_id << " to get notification settings";
return promise.set_error(Status::Error(400, "Can't access the chat"));
}

View File

@ -9,6 +9,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/GiveawayParameters.h"
#include "td/telegram/Global.h"
#include "td/telegram/InputInvoice.h"
@ -56,7 +57,7 @@ Result<InputInvoiceInfo> get_input_invoice_info(Td *td, td_api::object_ptr<td_ap
MessageId message_id(invoice->message_id_);
TRY_RESULT(server_message_id, td->messages_manager_->get_invoice_message_id({dialog_id, message_id}));
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
return Status::Error(400, "Can't access the chat");
}
@ -468,7 +469,7 @@ class GetPaymentFormQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPaymentFormQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetPaymentFormQuery");
promise_.set_error(std::move(status));
}
};
@ -513,7 +514,7 @@ class ValidateRequestedInfoQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ValidateRequestedInfoQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "ValidateRequestedInfoQuery");
promise_.set_error(std::move(status));
}
};
@ -578,7 +579,7 @@ class SendPaymentFormQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendPaymentFormQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "SendPaymentFormQuery");
promise_.set_error(std::move(status));
}
};
@ -594,7 +595,7 @@ class GetPaymentReceiptQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, ServerMessageId server_message_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
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"));
}
@ -641,7 +642,7 @@ class GetPaymentReceiptQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPaymentReceiptQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetPaymentReceiptQuery");
promise_.set_error(std::move(status));
}
};

View File

@ -12,6 +12,7 @@
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/MessageId.h"
@ -61,7 +62,7 @@ class GetPollResultsQuery final : public Td::ResultHandler {
poll_id_ = poll_id;
dialog_id_ = message_full_id.get_dialog_id();
message_id_ = message_full_id.get_message_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
if (input_peer == nullptr) {
LOG(INFO) << "Can't reget poll, because have no read access to " << dialog_id_;
return promise_.set_value(nullptr);
@ -102,7 +103,7 @@ class GetPollVotersQuery final : public Td::ResultHandler {
void send(PollId poll_id, MessageFullId message_full_id, BufferSlice &&option, const string &offset, int32 limit) {
poll_id_ = poll_id;
dialog_id_ = message_full_id.get_dialog_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
if (input_peer == nullptr) {
LOG(INFO) << "Can't get poll, because have no read access to " << dialog_id_;
return promise_.set_error(Status::Error(400, "Chat is not accessible"));
@ -129,7 +130,7 @@ class GetPollVotersQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPollVotersQuery") &&
if (!td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetPollVotersQuery") &&
status.message() != "MESSAGE_ID_INVALID") {
LOG(ERROR) << "Receive " << status << ", while trying to get voters of " << poll_id_;
}
@ -148,7 +149,7 @@ class SendVoteQuery final : public Td::ResultHandler {
void send(MessageFullId message_full_id, vector<BufferSlice> &&options, PollId poll_id, uint64 generation,
NetQueryRef *query_ref) {
dialog_id_ = message_full_id.get_dialog_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
if (input_peer == nullptr) {
LOG(INFO) << "Can't set poll answer, because have no read access to " << dialog_id_;
return on_error(Status::Error(400, "Can't access the chat"));
@ -174,7 +175,7 @@ class SendVoteQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendVoteQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "SendVoteQuery");
promise_.set_error(std::move(status));
}
};
@ -189,7 +190,7 @@ class StopPollQuery final : public Td::ResultHandler {
void send(MessageFullId message_full_id, unique_ptr<ReplyMarkup> &&reply_markup, PollId poll_id) {
dialog_id_ = message_full_id.get_dialog_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Edit);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Edit);
if (input_peer == nullptr) {
LOG(INFO) << "Can't close poll, because have no edit access to " << dialog_id_;
return on_error(Status::Error(400, "Can't access the chat"));
@ -228,7 +229,7 @@ class StopPollQuery final : public Td::ResultHandler {
if (!td_->auth_manager_->is_bot() && status.message() == "MESSAGE_NOT_MODIFIED") {
return promise_.set_value(Unit());
}
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "StopPollQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "StopPollQuery");
promise_.set_error(std::move(status));
}
};

View File

@ -12,6 +12,7 @@
#include "td/telegram/ChannelId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/GiveawayParameters.h"
@ -115,7 +116,7 @@ Result<telegram_api::object_ptr<telegram_api::InputPeer>> get_boost_input_peer(T
if (!td->contacts_manager_->get_channel_status(dialog_id.get_channel_id()).is_administrator()) {
return Status::Error(400, "Not enough rights in the chat");
}
auto boost_input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto boost_input_peer = td->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
CHECK(boost_input_peer != nullptr);
return std::move(boost_input_peer);
}
@ -296,7 +297,7 @@ class GetPremiumGiftCodeOptionsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(boosted_dialog_id_, status, "GetPremiumGiftCodeOptionsQuery");
td_->dialog_manager_->on_get_dialog_error(boosted_dialog_id_, status, "GetPremiumGiftCodeOptionsQuery");
promise_.set_error(std::move(status));
}
};
@ -333,7 +334,7 @@ class CheckGiftCodeQuery final : public Td::ResultHandler {
if (result->from_id_ != nullptr) {
creator_dialog_id = DialogId(result->from_id_);
if (!creator_dialog_id.is_valid() ||
!td_->messages_manager_->have_dialog_info_force(creator_dialog_id, "CheckGiftCodeQuery")) {
!td_->dialog_manager_->have_dialog_info_force(creator_dialog_id, "CheckGiftCodeQuery")) {
LOG(ERROR) << "Receive " << to_string(result);
return on_error(Status::Error(500, "Receive invalid response"));
}
@ -403,7 +404,7 @@ class LaunchPrepaidGiveawayQuery final : public Td::ResultHandler {
void send(int64 giveaway_id, const GiveawayParameters &parameters) {
auto dialog_id = parameters.get_boosted_dialog_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
CHECK(input_peer != nullptr);
send_query(G()->net_query_creator().create(telegram_api::payments_launchPrepaidGiveaway(
std::move(input_peer), giveaway_id, parameters.get_input_store_payment_premium_giveaway(td_, string(), 0))));
@ -436,7 +437,7 @@ class GetGiveawayInfoQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, ServerMessageId server_message_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
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"));
}
@ -513,7 +514,7 @@ class GetGiveawayInfoQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGiveawayInfoQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetGiveawayInfoQuery");
promise_.set_error(std::move(status));
}
};

View File

@ -9,6 +9,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogListId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/FolderId.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessagesManager.h"
@ -141,8 +142,8 @@ void RecentDialogList::on_load_dialogs(vector<string> &&found_dialogs) {
dialog_id = DialogId(to_integer<int64>(*it));
}
if (dialog_id.is_valid() && removed_dialog_ids_.count(dialog_id) == 0 &&
td_->messages_manager_->have_dialog_info(dialog_id) &&
td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
td_->dialog_manager_->have_dialog_info(dialog_id) &&
td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
td_->messages_manager_->force_create_dialog(dialog_id, "recent dialog");
do_add_dialog(dialog_id);
}

View File

@ -8,6 +8,7 @@
#include "td/telegram/ChannelId.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/LinkManager.h"
#include "td/telegram/MessageContent.h"
@ -387,7 +388,7 @@ void SponsoredMessageManager::on_get_dialog_sponsored_messages(
if (sponsored_message->from_id_ != nullptr) {
sponsor_dialog_id = DialogId(sponsored_message->from_id_);
if (!sponsor_dialog_id.is_valid() ||
!td_->messages_manager_->have_dialog_info_force(sponsor_dialog_id, "on_get_dialog_sponsored_messages")) {
!td_->dialog_manager_->have_dialog_info_force(sponsor_dialog_id, "on_get_dialog_sponsored_messages")) {
LOG(ERROR) << "Receive unknown sponsor " << sponsor_dialog_id;
continue;
}

View File

@ -8,6 +8,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/MessagesManager.h"
@ -330,7 +331,7 @@ class GetStoryStatsQuery final : public Td::ResultHandler {
void send(ChannelId channel_id, StoryId story_id, bool is_dark, DcId dc_id) {
channel_id_ = channel_id;
auto input_peer = td_->messages_manager_->get_input_peer(DialogId(channel_id), AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(DialogId(channel_id), AccessRights::Read);
if (input_peer == nullptr) {
return promise_.set_error(Status::Error(400, "Chat not found"));
}
@ -421,7 +422,7 @@ class GetMessagePublicForwardsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetMessagePublicForwardsQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetMessagePublicForwardsQuery");
promise_.set_error(std::move(status));
}
};
@ -438,7 +439,7 @@ class GetStoryPublicForwardsQuery final : public Td::ResultHandler {
void send(DcId dc_id, StoryFullId story_full_id, const string &offset, int32 limit) {
dialog_id_ = story_full_id.get_dialog_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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 get story statistics"));
}
@ -460,7 +461,7 @@ class GetStoryPublicForwardsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetStoryPublicForwardsQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetStoryPublicForwardsQuery");
promise_.set_error(std::move(status));
}
};

View File

@ -11,6 +11,7 @@
#include "td/telegram/ConfigManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/EmojiGroup.hpp"
@ -1532,7 +1533,7 @@ class SendAnimatedEmojiClicksQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendAnimatedEmojiClicksQuery")) {
if (!td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "SendAnimatedEmojiClicksQuery")) {
LOG(INFO) << "Receive error for send animated emoji clicks: " << status;
}
@ -6733,7 +6734,7 @@ void StickersManager::flush_pending_animated_emoji_clicks() {
return;
}
auto dialog_id = message_full_id.get_dialog_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
return;
}
@ -6878,7 +6879,7 @@ void StickersManager::schedule_update_animated_emoji_clicked(const StickerSet *s
return;
}
auto dialog_id = message_full_id.get_dialog_id();
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
return;
}
@ -6927,7 +6928,7 @@ void StickersManager::send_update_animated_emoji_clicked(MessageFullId message_f
return;
}
auto dialog_id = message_full_id.get_dialog_id();
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Write)) {
return;
}
@ -8047,7 +8048,7 @@ void StickersManager::do_upload_sticker_file(UserId user_id, FileId file_id,
TRY_STATUS_PROMISE(promise, G()->close_status());
DialogId dialog_id(user_id);
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
if (input_peer == nullptr) {
if (input_file != nullptr) {
td_->file_manager_->cancel_upload(file_id);

View File

@ -11,6 +11,7 @@
#include "td/telegram/ConfigManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/FileReferenceManager.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Global.h"
@ -147,7 +148,7 @@ class ToggleStoriesHiddenQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, bool are_hidden) {
dialog_id_ = dialog_id;
are_hidden_ = are_hidden;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -170,7 +171,7 @@ class ToggleStoriesHiddenQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ToggleStoriesHiddenQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "ToggleStoriesHiddenQuery");
promise_.set_error(std::move(status));
}
};
@ -235,7 +236,7 @@ class IncrementStoryViewsQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, const vector<StoryId> &story_ids) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -254,7 +255,7 @@ class IncrementStoryViewsQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "IncrementStoryViewsQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "IncrementStoryViewsQuery");
promise_.set_error(std::move(status));
}
};
@ -269,7 +270,7 @@ class ReadStoriesQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, StoryId max_read_story_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -287,7 +288,7 @@ class ReadStoriesQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReadStoriesQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "ReadStoriesQuery");
promise_.set_error(std::move(status));
}
};
@ -303,7 +304,7 @@ class SendStoryReactionQuery final : public Td::ResultHandler {
void send(StoryFullId story_full_id, const ReactionType &reaction_type, bool add_to_recent) {
dialog_id_ = story_full_id.get_dialog_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -334,7 +335,7 @@ class SendStoryReactionQuery final : public Td::ResultHandler {
if (status.message() == "STORY_NOT_MODIFIED") {
return promise_.set_value(Unit());
}
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendStoryReactionQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "SendStoryReactionQuery");
promise_.set_error(std::move(status));
}
};
@ -351,7 +352,7 @@ class GetStoryViewsListQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, StoryId story_id, const string &query, bool only_contacts, bool prefer_forwards,
bool prefer_with_reaction, const string &offset, int32 limit) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -386,7 +387,7 @@ class GetStoryViewsListQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetStoryViewsListQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetStoryViewsListQuery");
promise_.set_error(std::move(status));
}
};
@ -404,7 +405,7 @@ class GetStoryReactionsListQuery final : public Td::ResultHandler {
void send(StoryFullId story_full_id, const ReactionType &reaction_type, bool prefer_forwards, const string &offset,
int32 limit) {
dialog_id_ = story_full_id.get_dialog_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -436,7 +437,7 @@ class GetStoryReactionsListQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetStoryReactionsListQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetStoryReactionsListQuery");
promise_.set_error(std::move(status));
}
};
@ -453,7 +454,7 @@ class GetStoriesByIDQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, vector<StoryId> story_ids) {
dialog_id_ = dialog_id;
story_ids_ = std::move(story_ids);
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -474,7 +475,7 @@ class GetStoriesByIDQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetStoriesByIDQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetStoriesByIDQuery");
promise_.set_error(std::move(status));
}
};
@ -490,7 +491,7 @@ class GetPinnedStoriesQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, StoryId offset_story_id, int32 limit) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -510,7 +511,7 @@ class GetPinnedStoriesQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPinnedStoriesQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetPinnedStoriesQuery");
promise_.set_error(std::move(status));
}
};
@ -526,7 +527,7 @@ class GetStoriesArchiveQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, StoryId offset_story_id, int32 limit) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -546,7 +547,7 @@ class GetStoriesArchiveQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetStoriesArchiveQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetStoriesArchiveQuery");
promise_.set_error(std::move(status));
}
};
@ -562,7 +563,7 @@ class GetPeerStoriesQuery final : public Td::ResultHandler {
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -582,7 +583,7 @@ class GetPeerStoriesQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPeerStoriesQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetPeerStoriesQuery");
promise_.set_error(std::move(status));
}
};
@ -597,7 +598,7 @@ class EditStoryPrivacyQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, StoryId story_id, UserPrivacySettingRules &&privacy_rules) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -626,7 +627,7 @@ class EditStoryPrivacyQuery final : public Td::ResultHandler {
if (!td_->auth_manager_->is_bot() && status.message() == "STORY_NOT_MODIFIED") {
return promise_.set_value(Unit());
}
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditStoryPrivacyQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "EditStoryPrivacyQuery");
promise_.set_error(std::move(status));
}
};
@ -641,7 +642,7 @@ class ToggleStoryPinnedQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, StoryId story_id, bool is_pinned) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -662,7 +663,7 @@ class ToggleStoryPinnedQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ToggleStoryPinnedQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "ToggleStoryPinnedQuery");
promise_.set_error(std::move(status));
}
};
@ -677,7 +678,7 @@ class DeleteStoriesQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, const vector<StoryId> &story_ids) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -697,7 +698,7 @@ class DeleteStoriesQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteStoriesQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "DeleteStoriesQuery");
promise_.set_error(std::move(status));
}
};
@ -710,7 +711,7 @@ class GetStoriesViewsQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, vector<StoryId> story_ids) {
dialog_id_ = dialog_id;
story_ids_ = std::move(story_ids);
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -731,7 +732,7 @@ class GetStoriesViewsQuery final : public Td::ResultHandler {
void on_error(Status status) final {
LOG(INFO) << "Receive error for GetStoriesViewsQuery for " << story_ids_ << ": " << status;
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetStoriesViewsQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "GetStoriesViewsQuery");
}
};
@ -745,7 +746,7 @@ class ReportStoryQuery final : public Td::ResultHandler {
void send(StoryFullId story_full_id, ReportReason &&report_reason) {
dialog_id_ = story_full_id.get_dialog_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -765,7 +766,7 @@ class ReportStoryQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReportStoryQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "ReportStoryQuery");
promise_.set_error(std::move(status));
}
};
@ -855,7 +856,7 @@ class CanSendStoryQuery final : public Td::ResultHandler {
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -876,7 +877,7 @@ class CanSendStoryQuery final : public Td::ResultHandler {
if (result != nullptr) {
return promise_.set_value(std::move(result));
}
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "CanSendStoryQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "CanSendStoryQuery");
promise_.set_error(std::move(status));
}
};
@ -900,15 +901,15 @@ class StoryManager::SendStoryQuery final : public Td::ResultHandler {
auto input_media = get_story_content_input_media(td_, content, std::move(input_file));
CHECK(input_media != nullptr);
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
telegram_api::object_ptr<telegram_api::InputPeer> fwd_input_peer;
int32 fwd_story_id = 0;
if (story->forward_info_ != nullptr) {
fwd_input_peer = td_->messages_manager_->get_input_peer(
pending_story_->forward_from_story_full_id_.get_dialog_id(), AccessRights::Read);
fwd_input_peer = td_->dialog_manager_->get_input_peer(pending_story_->forward_from_story_full_id_.get_dialog_id(),
AccessRights::Read);
if (fwd_input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the story to repost"));
}
@ -985,7 +986,7 @@ class StoryManager::SendStoryQuery final : public Td::ResultHandler {
return;
}
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendStoryQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "SendStoryQuery");
td_->story_manager_->delete_pending_story(file_id_, std::move(pending_story_), std::move(status));
}
};
@ -1003,7 +1004,7 @@ class StoryManager::EditStoryQuery final : public Td::ResultHandler {
CHECK(pending_story_ != nullptr);
dialog_id_ = pending_story_->dialog_id_;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Write);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Write);
if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat"));
}
@ -1076,7 +1077,7 @@ class StoryManager::EditStoryQuery final : public Td::ResultHandler {
return;
}
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditStoryQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "EditStoryQuery");
td_->story_manager_->delete_pending_story(file_id_, std::move(pending_story_), std::move(status));
}
};
@ -2265,7 +2266,7 @@ void StoryManager::toggle_dialog_stories_hidden(DialogId dialog_id, StoryListId
if (!td_->messages_manager_->have_dialog_force(dialog_id, "toggle_dialog_stories_hidden")) {
return promise.set_error(Status::Error(400, "Story sender not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the story sender"));
}
if (story_list_id == get_dialog_story_list_id(dialog_id)) {
@ -2288,7 +2289,7 @@ void StoryManager::get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId f
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "get_dialog_pinned_stories")) {
return promise.set_error(Status::Error(400, "Story sender not found"));
}
if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the story sender"));
}
@ -2362,7 +2363,7 @@ void StoryManager::get_dialog_expiring_stories(DialogId owner_dialog_id,
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "get_dialog_expiring_stories")) {
return promise.set_error(Status::Error(400, "Story sender not found"));
}
if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the story sender"));
}
@ -2392,7 +2393,7 @@ void StoryManager::get_dialog_expiring_stories(DialogId owner_dialog_id,
}
void StoryManager::reload_dialog_expiring_stories(DialogId dialog_id) {
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return;
}
td_->messages_manager_->force_create_dialog(dialog_id, "reload_dialog_expiring_stories");
@ -2482,7 +2483,7 @@ void StoryManager::open_story(DialogId owner_dialog_id, StoryId story_id, Promis
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "open_story")) {
return promise.set_error(Status::Error(400, "Story sender not found"));
}
if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the story sender"));
}
if (!story_id.is_valid()) {
@ -2545,7 +2546,7 @@ void StoryManager::close_story(DialogId owner_dialog_id, StoryId story_id, Promi
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "close_story")) {
return promise.set_error(Status::Error(400, "Story sender not found"));
}
if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the story sender"));
}
if (!story_id.is_valid()) {
@ -2657,7 +2658,7 @@ void StoryManager::set_story_reaction(StoryFullId story_full_id, ReactionType re
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "set_story_reaction")) {
return promise.set_error(Status::Error(400, "Story sender not found"));
}
if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the story sender"));
}
if (!story_full_id.get_story_id().is_valid()) {
@ -4193,7 +4194,7 @@ void StoryManager::on_update_story_id(int64 random_id, StoryId new_story_id, con
}
bool StoryManager::on_update_read_stories(DialogId owner_dialog_id, StoryId max_read_story_id) {
if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id, "on_update_read_stories")) {
if (!td_->dialog_manager_->have_dialog_info_force(owner_dialog_id, "on_update_read_stories")) {
LOG(INFO) << "Can't read stories in unknown " << owner_dialog_id;
return false;
}
@ -4245,7 +4246,7 @@ void StoryManager::on_update_story_chosen_reaction_type(DialogId owner_dialog_id
LOG(ERROR) << "Receive chosen reaction in " << story_id << " in " << owner_dialog_id;
return;
}
if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id, "on_update_story_chosen_reaction_type")) {
if (!td_->dialog_manager_->have_dialog_info_force(owner_dialog_id, "on_update_story_chosen_reaction_type")) {
return;
}
StoryFullId story_full_id{owner_dialog_id, story_id};
@ -4476,7 +4477,7 @@ void StoryManager::get_story(DialogId owner_dialog_id, StoryId story_id, bool on
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "get_story")) {
return promise.set_error(Status::Error(400, "Story sender not found"));
}
if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
if (!td_->dialog_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the story sender"));
}
if (!story_id.is_valid()) {
@ -5353,7 +5354,7 @@ void StoryManager::delete_story_on_server(StoryFullId story_full_id, uint64 log_
telegram_api::object_ptr<telegram_api::InputMedia> StoryManager::get_input_media(StoryFullId story_full_id) const {
auto dialog_id = story_full_id.get_dialog_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
return nullptr;
}

View File

@ -3997,6 +3997,7 @@ void Td::init_managers() {
G()->set_dialog_filter_manager(dialog_filter_manager_actor_.get());
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());
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());
@ -6530,14 +6531,14 @@ void Td::on_request(uint64 id, const td_api::setChatPhoto &request) {
void Td::on_request(uint64 id, const td_api::setChatAccentColor &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
messages_manager_->set_dialog_accent_color(DialogId(request.chat_id_), AccentColorId(request.accent_color_id_),
CustomEmojiId(request.background_custom_emoji_id_), std::move(promise));
dialog_manager_->set_dialog_accent_color(DialogId(request.chat_id_), AccentColorId(request.accent_color_id_),
CustomEmojiId(request.background_custom_emoji_id_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::setChatProfileAccentColor &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
messages_manager_->set_dialog_profile_accent_color(
dialog_manager_->set_dialog_profile_accent_color(
DialogId(request.chat_id_), AccentColorId(request.profile_accent_color_id_),
CustomEmojiId(request.profile_background_custom_emoji_id_), std::move(promise));
}
@ -6552,8 +6553,8 @@ void Td::on_request(uint64 id, const td_api::setChatMessageAutoDeleteTime &reque
void Td::on_request(uint64 id, const td_api::setChatEmojiStatus &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
messages_manager_->set_dialog_emoji_status(DialogId(request.chat_id_), EmojiStatus(request.emoji_status_),
std::move(promise));
dialog_manager_->set_dialog_emoji_status(DialogId(request.chat_id_), EmojiStatus(request.emoji_status_),
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::setChatPermissions &request) {
@ -6815,7 +6816,7 @@ void Td::on_request(uint64 id, td_api::setChatClientData &request) {
void Td::on_request(uint64 id, td_api::setChatDescription &request) {
CLEAN_INPUT_STRING(request.description_);
CREATE_OK_REQUEST_PROMISE();
messages_manager_->set_dialog_description(DialogId(request.chat_id_), request.description_, std::move(promise));
dialog_manager_->set_dialog_description(DialogId(request.chat_id_), request.description_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::setChatDiscussionGroup &request) {

View File

@ -10,6 +10,7 @@
#include "td/telegram/AuthManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/MessagesManager.h"
@ -101,7 +102,7 @@ class ResetTopPeerRatingQuery final : public Td::ResultHandler {
public:
void send(TopDialogCategory category, DialogId dialog_id) {
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
return;
}
@ -121,7 +122,7 @@ class ResetTopPeerRatingQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ResetTopPeerRatingQuery")) {
if (!td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "ResetTopPeerRatingQuery")) {
LOG(INFO) << "Receive error for ResetTopPeerRatingQuery: " << status;
}
}

View File

@ -8,6 +8,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h"
@ -27,7 +28,7 @@ class TranscribeAudioQuery final : public Td::ResultHandler {
std::function<void(Result<telegram_api::object_ptr<telegram_api::messages_transcribedAudio>>)> &&handler) {
dialog_id_ = message_full_id.get_dialog_id();
handler_ = std::move(handler);
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -49,7 +50,7 @@ class TranscribeAudioQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "TranscribeAudioQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "TranscribeAudioQuery");
handler_(std::move(status));
}
};
@ -64,7 +65,7 @@ class RateTranscribedAudioQuery final : public Td::ResultHandler {
void send(MessageFullId message_full_id, int64 transcription_id, bool is_good) {
dialog_id_ = message_full_id.get_dialog_id();
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
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"));
}
@ -85,7 +86,7 @@ class RateTranscribedAudioQuery final : public Td::ResultHandler {
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "RateTranscribedAudioQuery");
td_->dialog_manager_->on_get_dialog_error(dialog_id_, status, "RateTranscribedAudioQuery");
promise_.set_error(std::move(status));
}
};