Use DialogManager::get_my_dialog_id.

This commit is contained in:
levlam 2024-01-04 15:49:02 +03:00
parent eb5a37e927
commit ebda6f1364
10 changed files with 24 additions and 23 deletions

View File

@ -53,7 +53,7 @@ class CreateForumTopicQuery final : public Td::ResultHandler {
void send(ChannelId channel_id, const string &title, int32 icon_color, CustomEmojiId icon_custom_emoji_id,
DialogId as_dialog_id) {
channel_id_ = channel_id;
creator_dialog_id_ = DialogId(td_->contacts_manager_->get_my_id());
creator_dialog_id_ = td_->dialog_manager_->get_my_dialog_id();
int32 flags = 0;
if (icon_color != -1) {

View File

@ -1305,7 +1305,7 @@ void GroupCallManager::set_group_call_default_join_as(DialogId dialog_id, Dialog
switch (as_dialog_id.get_type()) {
case DialogType::User:
if (as_dialog_id != DialogId(td_->contacts_manager_->get_my_id())) {
if (as_dialog_id != td_->dialog_manager_->get_my_dialog_id()) {
return promise.set_error(Status::Error(400, "Can't join voice chat as another user"));
}
break;
@ -1723,7 +1723,7 @@ GroupCallParticipant *GroupCallManager::get_group_call_participant(GroupCallPart
if (!dialog_id.is_valid()) {
return nullptr;
}
if (dialog_id == DialogId(td_->contacts_manager_->get_my_id())) {
if (dialog_id == td_->dialog_manager_->get_my_dialog_id()) {
for (auto &group_call_participant : group_call_participants->participants) {
if (group_call_participant.is_self) {
return &group_call_participant;
@ -2242,7 +2242,7 @@ void GroupCallManager::process_my_group_call_participant(InputGroupCallId input_
return;
}
auto my_participant = get_group_call_participant(add_group_call_participants(input_group_call_id),
DialogId(td_->contacts_manager_->get_my_id()));
td_->dialog_manager_->get_my_dialog_id());
if (my_participant == nullptr || my_participant->is_fake || my_participant->joined_date < participant.joined_date ||
(my_participant->joined_date <= participant.joined_date &&
my_participant->audio_source != participant.audio_source)) {
@ -2631,7 +2631,7 @@ void GroupCallManager::join_group_call(GroupCallId group_call_id, DialogId as_di
bool have_as_dialog_id = true;
{
auto my_dialog_id = DialogId(td_->contacts_manager_->get_my_id());
auto my_dialog_id = td_->dialog_manager_->get_my_dialog_id();
if (!as_dialog_id.is_valid()) {
as_dialog_id = my_dialog_id;
}
@ -2844,7 +2844,7 @@ void GroupCallManager::finish_load_group_call_administrators(InputGroupCallId in
auto participants = result.move_as_ok();
for (auto &administrator : participants.participants_) {
if (administrator.status_.can_manage_calls() &&
administrator.dialog_id_ != DialogId(td_->contacts_manager_->get_my_id())) {
administrator.dialog_id_ != td_->dialog_manager_->get_my_dialog_id()) {
administrator_dialog_ids.push_back(administrator.dialog_id_);
}
}

View File

@ -377,7 +377,7 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
auto constructor_id = input_message_content->get_id();
if (constructor_id == td_api::inputMessageText::ID) {
TRY_RESULT(input_message_text, process_input_message_text(td_, DialogId(td_->contacts_manager_->get_my_id()),
TRY_RESULT(input_message_text, process_input_message_text(td_, td_->dialog_manager_->get_my_dialog_id(),
std::move(input_message_content), true));
auto entities = get_input_message_entities(td_->contacts_manager_.get(), input_message_text.text.entities,
"get_inline_message");
@ -453,7 +453,7 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
return venue.get_input_bot_inline_message_media_venue(std::move(input_reply_markup));
}
if (constructor_id == allowed_media_content_id) {
TRY_RESULT(caption, get_formatted_text(td_, DialogId(td_->contacts_manager_->get_my_id()),
TRY_RESULT(caption, get_formatted_text(td_, td_->dialog_manager_->get_my_dialog_id(),
extract_input_caption(input_message_content), true, true, true, false));
int32 flags = 0;
if (input_reply_markup != nullptr) {

View File

@ -8,6 +8,7 @@
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/LinkManager.h"
#include "td/telegram/misc.h"
#include "td/telegram/OptionManager.h"
@ -4725,8 +4726,7 @@ void remove_unallowed_entities(const Td *td, FormattedText &text, DialogId dialo
remove_intersecting_entities(text.entities);
}
}
if (dialog_id != DialogId(td->contacts_manager_->get_my_id()) &&
!td->contacts_manager_->can_use_premium_custom_emoji()) {
if (dialog_id != td->dialog_manager_->get_my_dialog_id() && !td->contacts_manager_->can_use_premium_custom_emoji()) {
remove_premium_custom_emoji_entities(td, text.entities, false);
}
}

View File

@ -24732,7 +24732,7 @@ void MessagesManager::set_dialog_default_send_message_as_dialog_id(DialogId dial
bool is_anonymous = td_->dialog_manager_->is_anonymous_administrator(dialog_id, nullptr);
switch (message_sender_dialog_id.get_type()) {
case DialogType::User:
if (message_sender_dialog_id != DialogId(td_->contacts_manager_->get_my_id())) {
if (message_sender_dialog_id != td_->dialog_manager_->get_my_dialog_id()) {
return promise.set_error(Status::Error(400, "Can't send messages as another user"));
}
if (is_anonymous) {

View File

@ -6,8 +6,8 @@
//
#include "td/telegram/RepliedMessageInfo.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/MessageContent.h"
#include "td/telegram/MessageContentType.h"
#include "td/telegram/MessageCopyOptions.h"
@ -180,7 +180,7 @@ RepliedMessageInfo RepliedMessageInfo::clone(Td *td) const {
result.origin_date_ = origin_date_;
result.origin_ = origin_;
if (content_ != nullptr) {
result.content_ = dup_message_content(td, DialogId(td->contacts_manager_->get_my_id()), content_.get(),
result.content_ = dup_message_content(td, td->dialog_manager_->get_my_dialog_id(), content_.get(),
MessageContentDupType::Forward, MessageCopyOptions());
}
result.quote_ = quote_;

View File

@ -621,7 +621,7 @@ void StatisticsManager::get_story_public_forwards(StoryFullId story_full_id, str
}
auto dialog_id = story_full_id.get_dialog_id();
if (dialog_id.get_type() == DialogType::User) {
if (dialog_id != DialogId(td_->contacts_manager_->get_my_id())) {
if (dialog_id != td_->dialog_manager_->get_my_dialog_id()) {
return promise.set_error(Status::Error(400, "Have no access to story statistics"));
}
return send_get_story_public_forwards_query(DcId::main(), story_full_id, std::move(offset), limit,
@ -646,7 +646,7 @@ void StatisticsManager::send_get_story_public_forwards_query(
return promise.set_error(Status::Error(400, "Story not found"));
}
if (!td_->story_manager_->can_get_story_statistics(story_full_id) &&
story_full_id.get_dialog_id() != DialogId(td_->contacts_manager_->get_my_id())) {
story_full_id.get_dialog_id() != td_->dialog_manager_->get_my_dialog_id()) {
return promise.set_error(Status::Error(400, "Story forwards are inaccessible"));
}

View File

@ -1581,7 +1581,7 @@ void StoryManager::on_load_expired_database_stories(vector<StoryDbStory> stories
}
bool StoryManager::is_my_story(DialogId owner_dialog_id) const {
return owner_dialog_id == DialogId(td_->contacts_manager_->get_my_id());
return owner_dialog_id == td_->dialog_manager_->get_my_dialog_id();
}
bool StoryManager::can_access_expired_story(DialogId owner_dialog_id, const Story *story) const {
@ -2880,7 +2880,7 @@ void StoryManager::get_story_interactions(StoryId story_id, const string &query,
bool prefer_forwards, bool prefer_with_reaction, const string &offset,
int32 limit,
Promise<td_api::object_ptr<td_api::storyInteractions>> &&promise) {
DialogId owner_dialog_id(td_->contacts_manager_->get_my_id());
auto owner_dialog_id = td_->dialog_manager_->get_my_dialog_id();
StoryFullId story_full_id{owner_dialog_id, story_id};
const Story *story = get_story(story_full_id);
if (story == nullptr) {
@ -2913,7 +2913,7 @@ void StoryManager::on_get_story_interactions(
}
auto view_list = r_view_list.move_as_ok();
DialogId owner_dialog_id(td_->contacts_manager_->get_my_id());
auto owner_dialog_id = td_->dialog_manager_->get_my_dialog_id();
CHECK(story_id.is_server());
StoryFullId story_full_id{owner_dialog_id, story_id};
Story *story = get_story_editable(story_full_id);
@ -4033,7 +4033,7 @@ bool StoryManager::update_active_stories_order(DialogId owner_dialog_id, ActiveS
if (active_stories->max_read_story_id_.get() < last_story_id.get()) {
new_private_order += static_cast<int64>(1) << 35;
}
if (owner_dialog_id == DialogId(td_->contacts_manager_->get_my_id())) {
if (owner_dialog_id == td_->dialog_manager_->get_my_dialog_id()) {
new_private_order += static_cast<int64>(1) << 36;
}
CHECK(new_private_order != 0);

View File

@ -8,6 +8,7 @@
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/Td.h"
@ -129,9 +130,9 @@ void get_user_info(Td *td, UserId user_id, Promise<td_api::object_ptr<td_api::us
void set_user_info(Td *td, UserId user_id, td_api::object_ptr<td_api::formattedText> &&message,
Promise<td_api::object_ptr<td_api::userSupportInfo>> &&promise) {
TRY_RESULT_PROMISE(promise, formatted_text,
get_formatted_text(td, DialogId(td->contacts_manager_->get_my_id()), std::move(message), false,
true, true, false));
TRY_RESULT_PROMISE(
promise, formatted_text,
get_formatted_text(td, td->dialog_manager_->get_my_dialog_id(), std::move(message), false, true, true, false));
td->create_handler<EditUserInfoQuery>(std::move(promise))->send(user_id, std::move(formatted_text));
}

View File

@ -6889,7 +6889,7 @@ void Td::on_request(uint64 id, const td_api::leaveChat &request) {
td_api::make_object<td_api::chatMemberStatusCreator>(status.get_rank(), status.is_anonymous(), false);
}
}
contacts_manager_->set_dialog_participant_status(dialog_id, DialogId(contacts_manager_->get_my_id()),
contacts_manager_->set_dialog_participant_status(dialog_id, dialog_manager_->get_my_dialog_id(),
std::move(new_status), std::move(promise));
}