Pass UserManager to get_text_entity_object.

This commit is contained in:
levlam 2024-07-21 12:33:02 +03:00
parent 8330062bfb
commit c9a92f64d6
28 changed files with 123 additions and 94 deletions

View File

@ -21,9 +21,10 @@ BusinessChatLink::BusinessChatLink(const UserManager *user_manager,
, view_count_(link->views_) {
}
td_api::object_ptr<td_api::businessChatLink> BusinessChatLink::get_business_chat_link_object() const {
return td_api::make_object<td_api::businessChatLink>(link_, get_formatted_text_object(text_, true, -1), title_,
view_count_);
td_api::object_ptr<td_api::businessChatLink> BusinessChatLink::get_business_chat_link_object(
const UserManager *user_manager) const {
return td_api::make_object<td_api::businessChatLink>(link_, get_formatted_text_object(user_manager, text_, true, -1),
title_, view_count_);
}
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessChatLink &link) {
@ -41,9 +42,11 @@ BusinessChatLinks::BusinessChatLinks(const UserManager *user_manager,
}
}
td_api::object_ptr<td_api::businessChatLinks> BusinessChatLinks::get_business_chat_links_object() const {
td_api::object_ptr<td_api::businessChatLinks> BusinessChatLinks::get_business_chat_links_object(
const UserManager *user_manager) const {
return td_api::make_object<td_api::businessChatLinks>(transform(
business_chat_links_, [](const BusinessChatLink &link) { return link.get_business_chat_link_object(); }));
business_chat_links_,
[user_manager](const BusinessChatLink &link) { return link.get_business_chat_link_object(user_manager); }));
}
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessChatLinks &links) {

View File

@ -32,7 +32,7 @@ class BusinessChatLink {
return !link_.empty();
}
td_api::object_ptr<td_api::businessChatLink> get_business_chat_link_object() const;
td_api::object_ptr<td_api::businessChatLink> get_business_chat_link_object(const UserManager *user_manager) const;
};
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessChatLink &link);
@ -46,7 +46,7 @@ class BusinessChatLinks {
explicit BusinessChatLinks(const UserManager *user_manager,
vector<telegram_api::object_ptr<telegram_api::businessChatLink>> &&links);
td_api::object_ptr<td_api::businessChatLinks> get_business_chat_links_object() const;
td_api::object_ptr<td_api::businessChatLinks> get_business_chat_links_object(const UserManager *user_manager) const;
};
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessChatLinks &links);

View File

@ -207,8 +207,8 @@ class GetBusinessChatLinksQuery final : public Td::ResultHandler {
LOG(INFO) << "Receive result for GetBusinessChatLinksQuery: " << to_string(ptr);
td_->user_manager_->on_get_users(std::move(ptr->users_), "GetBusinessChatLinksQuery");
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "GetBusinessChatLinksQuery");
promise_.set_value(
BusinessChatLinks(td_->user_manager_.get(), std::move(ptr->links_)).get_business_chat_links_object());
promise_.set_value(BusinessChatLinks(td_->user_manager_.get(), std::move(ptr->links_))
.get_business_chat_links_object(td_->user_manager_.get()));
}
void on_error(Status status) final {
@ -238,7 +238,8 @@ class CreateBusinessChatLinkQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for CreateBusinessChatLinkQuery: " << to_string(ptr);
promise_.set_value(BusinessChatLink(td_->user_manager_.get(), std::move(ptr)).get_business_chat_link_object());
promise_.set_value(BusinessChatLink(td_->user_manager_.get(), std::move(ptr))
.get_business_chat_link_object(td_->user_manager_.get()));
}
void on_error(Status status) final {
@ -269,7 +270,8 @@ class EditBusinessChatLinkQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for EditBusinessChatLinkQuery: " << to_string(ptr);
promise_.set_value(BusinessChatLink(td_->user_manager_.get(), std::move(ptr)).get_business_chat_link_object());
promise_.set_value(BusinessChatLink(td_->user_manager_.get(), std::move(ptr))
.get_business_chat_link_object(td_->user_manager_.get()));
}
void on_error(Status status) final {
@ -343,7 +345,7 @@ class ResolveBusinessChatLinkQuery final : public Td::ResultHandler {
promise_.set_value(td_api::make_object<td_api::businessChatLinkInfo>(
td_->dialog_manager_->get_chat_id_object(dialog_id, "businessChatLinkInfo"),
get_formatted_text_object(text, true, -1)));
get_formatted_text_object(td_->user_manager_.get(), text, true, -1)));
}
void on_error(Status status) final {

View File

@ -404,7 +404,7 @@ td_api::object_ptr<td_api::draftMessage> DraftMessage::get_draft_message_object(
if (local_content_ != nullptr) {
input_message_content = local_content_->get_draft_input_message_content_object();
} else {
input_message_content = input_message_text_.get_input_message_text_object();
input_message_content = input_message_text_.get_input_message_text_object(td->user_manager_.get());
}
return td_api::make_object<td_api::draftMessage>(message_input_reply_to_.get_input_message_reply_to_object(td), date_,
std::move(input_message_content), message_effect_id_.get());

View File

@ -7,14 +7,14 @@
#include "td/telegram/FactCheck.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/Td.h"
#include "td/telegram/telegram_api.h"
namespace td {
FactCheck::~FactCheck() = default;
unique_ptr<FactCheck> FactCheck::get_fact_check(Td *td, telegram_api::object_ptr<telegram_api::factCheck> &&fact_check,
unique_ptr<FactCheck> FactCheck::get_fact_check(const UserManager *user_manager,
telegram_api::object_ptr<telegram_api::factCheck> &&fact_check,
bool is_bot) {
if (is_bot || fact_check == nullptr || fact_check->hash_ == 0) {
return nullptr;
@ -22,7 +22,7 @@ unique_ptr<FactCheck> FactCheck::get_fact_check(Td *td, telegram_api::object_ptr
auto result = make_unique<FactCheck>();
result->country_code_ = std::move(fact_check->country_);
if (fact_check->text_ != nullptr) {
result->text_ = get_formatted_text(td->user_manager_.get(), std::move(fact_check->text_), true, false, "factCheck");
result->text_ = get_formatted_text(user_manager, std::move(fact_check->text_), true, false, "factCheck");
}
result->hash_ = fact_check->hash_;
result->need_check_ = fact_check->need_check_;
@ -42,11 +42,12 @@ void FactCheck::add_dependencies(Dependencies &dependencies) const {
add_formatted_text_dependencies(dependencies, &text_);
}
td_api::object_ptr<td_api::factCheck> FactCheck::get_fact_check_object() const {
td_api::object_ptr<td_api::factCheck> FactCheck::get_fact_check_object(const UserManager *user_manager) const {
if (is_empty() || need_check_) {
return nullptr;
}
return td_api::make_object<td_api::factCheck>(get_formatted_text_object(text_, true, -1), country_code_);
return td_api::make_object<td_api::factCheck>(get_formatted_text_object(user_manager, text_, true, -1),
country_code_);
}
bool operator==(const unique_ptr<FactCheck> &lhs, const unique_ptr<FactCheck> &rhs) {

View File

@ -16,7 +16,7 @@ namespace td {
class Dependencies;
class Td;
class UserManager;
class FactCheck {
string country_code_;
@ -34,7 +34,8 @@ class FactCheck {
FactCheck &operator=(FactCheck &&) = default;
~FactCheck();
static unique_ptr<FactCheck> get_fact_check(Td *td, telegram_api::object_ptr<telegram_api::factCheck> &&fact_check,
static unique_ptr<FactCheck> get_fact_check(const UserManager *user_manager,
telegram_api::object_ptr<telegram_api::factCheck> &&fact_check,
bool is_bot);
bool is_empty() const {
@ -49,7 +50,7 @@ class FactCheck {
void add_dependencies(Dependencies &dependencies) const;
td_api::object_ptr<td_api::factCheck> get_fact_check_object() const;
td_api::object_ptr<td_api::factCheck> get_fact_check_object(const UserManager *user_manager) const;
template <class StorerT>
void store(StorerT &storer) const;

View File

@ -81,7 +81,8 @@ const FormattedText &Game::get_text() const {
}
tl_object_ptr<td_api::game> Game::get_game_object(Td *td, bool skip_bot_commands) const {
return make_tl_object<td_api::game>(id_, short_name_, title_, get_formatted_text_object(text_, skip_bot_commands, -1),
return make_tl_object<td_api::game>(id_, short_name_, title_,
get_formatted_text_object(td->user_manager_.get(), text_, skip_bot_commands, -1),
description_, get_photo_object(td->file_manager_.get(), photo_),
td->animations_manager_->get_animation_object(animation_file_id_));
}

View File

@ -251,10 +251,10 @@ Result<InputInvoice> InputInvoice::process_input_message_invoice(
td_api::object_ptr<td_api::messageInvoice> InputInvoice::get_message_invoice_object(Td *td, bool skip_bot_commands,
int32 max_media_timestamp) const {
auto extended_media_object = extended_media_.get_message_extended_media_object(td);
auto extended_media_caption_object =
extended_media_object == nullptr
? nullptr
: get_formatted_text_object(extended_media_caption_, skip_bot_commands, max_media_timestamp);
auto extended_media_caption_object = extended_media_object == nullptr
? nullptr
: get_formatted_text_object(td->user_manager_.get(), extended_media_caption_,
skip_bot_commands, max_media_timestamp);
return td_api::make_object<td_api::messageInvoice>(
get_product_info_object(td, title_, description_, photo_), invoice_.currency_, total_amount_, start_parameter_,
invoice_.is_test_, invoice_.need_shipping_address_, receipt_message_id_.get(), std::move(extended_media_object),
@ -441,8 +441,9 @@ td_api::object_ptr<td_api::productInfo> get_product_info_object(Td *td, const st
FormattedText formatted_description;
formatted_description.text = description;
formatted_description.entities = find_entities(formatted_description.text, true, true);
return td_api::make_object<td_api::productInfo>(title, get_formatted_text_object(formatted_description, true, 0),
get_photo_object(td->file_manager_.get(), photo));
return td_api::make_object<td_api::productInfo>(
title, get_formatted_text_object(td->user_manager_.get(), formatted_description, true, 0),
get_photo_object(td->file_manager_.get(), photo));
}
} // namespace td

View File

@ -91,14 +91,15 @@ telegram_api::object_ptr<telegram_api::InputMedia> InputMessageText::get_input_m
}
// used only for draft
td_api::object_ptr<td_api::inputMessageText> InputMessageText::get_input_message_text_object() const {
td_api::object_ptr<td_api::inputMessageText> InputMessageText::get_input_message_text_object(
const UserManager *user_manager) const {
td_api::object_ptr<td_api::linkPreviewOptions> options;
if (!web_page_url.empty() || disable_web_page_preview || force_small_media || force_large_media || show_above_text) {
options = td_api::make_object<td_api::linkPreviewOptions>(disable_web_page_preview, web_page_url, force_small_media,
force_large_media, show_above_text);
}
return td_api::make_object<td_api::inputMessageText>(get_formatted_text_object(text, false, -1), std::move(options),
clear_draft);
return td_api::make_object<td_api::inputMessageText>(get_formatted_text_object(user_manager, text, false, -1),
std::move(options), clear_draft);
}
} // namespace td

View File

@ -20,6 +20,8 @@ class Dependencies;
class Td;
class UserManager;
class InputMessageText {
public:
FormattedText text;
@ -50,7 +52,7 @@ class InputMessageText {
telegram_api::object_ptr<telegram_api::InputMedia> get_input_media_web_page() const;
td_api::object_ptr<td_api::inputMessageText> get_input_message_text_object() const;
td_api::object_ptr<td_api::inputMessageText> get_input_message_text_object(const UserManager *user_manager) const;
};
bool operator==(const InputMessageText &lhs, const InputMessageText &rhs);

View File

@ -545,8 +545,8 @@ class LinkManager::InternalLinkMessageDraft final : public InternalLink {
bool contains_link_ = false;
td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final {
return td_api::make_object<td_api::internalLinkTypeMessageDraft>(get_formatted_text_object(text_, true, -1),
contains_link_);
return td_api::make_object<td_api::internalLinkTypeMessageDraft>(
get_formatted_text_object(nullptr, text_, true, -1), contains_link_);
}
public:
@ -855,8 +855,8 @@ class GetDeepLinkInfoQuery final : public Td::ResultHandler {
auto info = telegram_api::move_object_as<telegram_api::help_deepLinkInfo>(result);
auto text = get_formatted_text(nullptr, std::move(info->message_), std::move(info->entities_), true, true,
"GetDeepLinkInfoQuery");
return promise_.set_value(
td_api::make_object<td_api::deepLinkInfo>(get_formatted_text_object(text, true, -1), info->update_app_));
return promise_.set_value(td_api::make_object<td_api::deepLinkInfo>(
get_formatted_text_object(td_->user_manager_.get(), text, true, -1), info->update_app_));
}
default:
UNREACHABLE();

View File

@ -7392,14 +7392,14 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
const auto *m = static_cast<const MessageAnimation *>(content);
return make_tl_object<td_api::messageAnimation>(
td->animations_manager_->get_animation_object(m->file_id),
get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp), invert_media, m->has_spoiler,
is_content_secret);
get_formatted_text_object(td->user_manager_.get(), m->caption, skip_bot_commands, max_media_timestamp),
invert_media, m->has_spoiler, is_content_secret);
}
case MessageContentType::Audio: {
const auto *m = static_cast<const MessageAudio *>(content);
return make_tl_object<td_api::messageAudio>(
td->audios_manager_->get_audio_object(m->file_id),
get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp));
get_formatted_text_object(td->user_manager_.get(), m->caption, skip_bot_commands, max_media_timestamp));
}
case MessageContentType::Contact: {
const auto *m = static_cast<const MessageContact *>(content);
@ -7409,7 +7409,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
const auto *m = static_cast<const MessageDocument *>(content);
return make_tl_object<td_api::messageDocument>(
td->documents_manager_->get_document_object(m->file_id, PhotoFormat::Jpeg),
get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp));
get_formatted_text_object(td->user_manager_.get(), m->caption, skip_bot_commands, max_media_timestamp));
}
case MessageContentType::Game: {
const auto *m = static_cast<const MessageGame *>(content);
@ -7439,7 +7439,8 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
LOG(ERROR) << "Have empty " << m->photo;
return make_tl_object<td_api::messageExpiredPhoto>();
}
auto caption = get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp);
auto caption =
get_formatted_text_object(td->user_manager_.get(), m->caption, skip_bot_commands, max_media_timestamp);
return make_tl_object<td_api::messagePhoto>(std::move(photo), std::move(caption), invert_media, m->has_spoiler,
is_content_secret);
}
@ -7479,8 +7480,8 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
disable_web_page_preview, m->web_page_url, m->force_small_media, m->force_large_media, invert_media);
}
return make_tl_object<td_api::messageText>(
get_formatted_text_object(m->text, skip_bot_commands, max_media_timestamp), std::move(web_page),
std::move(link_preview_options));
get_formatted_text_object(td->user_manager_.get(), m->text, skip_bot_commands, max_media_timestamp),
std::move(web_page), std::move(link_preview_options));
}
case MessageContentType::Unsupported:
return make_tl_object<td_api::messageUnsupported>();
@ -7492,8 +7493,8 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
const auto *m = static_cast<const MessageVideo *>(content);
return make_tl_object<td_api::messageVideo>(
td->videos_manager_->get_video_object(m->file_id),
get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp), invert_media, m->has_spoiler,
is_content_secret);
get_formatted_text_object(td->user_manager_.get(), m->caption, skip_bot_commands, max_media_timestamp),
invert_media, m->has_spoiler, is_content_secret);
}
case MessageContentType::VideoNote: {
const auto *m = static_cast<const MessageVideoNote *>(content);
@ -7504,7 +7505,8 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
const auto *m = static_cast<const MessageVoiceNote *>(content);
return make_tl_object<td_api::messageVoiceNote>(
td->voice_notes_manager_->get_voice_note_object(m->file_id),
get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp), m->is_listened);
get_formatted_text_object(td->user_manager_.get(), m->caption, skip_bot_commands, max_media_timestamp),
m->is_listened);
}
case MessageContentType::ChatCreate: {
const auto *m = static_cast<const MessageChatCreate *>(content);
@ -7795,7 +7797,8 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
return td_api::make_object<td_api::messagePaidMedia>(
m->star_count,
transform(m->media, [&](const auto &media) { return media.get_message_extended_media_object(td); }),
get_formatted_text_object(m->caption, skip_bot_commands, max_media_timestamp), invert_media);
get_formatted_text_object(td->user_manager_.get(), m->caption, skip_bot_commands, max_media_timestamp),
invert_media);
}
case MessageContentType::PaymentRefunded: {
const auto *m = static_cast<const MessagePaymentRefunded *>(content);

View File

@ -134,7 +134,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const MessageEntity &me
return string_builder;
}
tl_object_ptr<td_api::TextEntityType> MessageEntity::get_text_entity_type_object() const {
tl_object_ptr<td_api::TextEntityType> MessageEntity::get_text_entity_type_object(
const UserManager *user_manager) const {
switch (type) {
case MessageEntity::Type::Mention:
return make_tl_object<td_api::textEntityTypeMention>();
@ -165,8 +166,9 @@ tl_object_ptr<td_api::TextEntityType> MessageEntity::get_text_entity_type_object
case MessageEntity::Type::TextUrl:
return make_tl_object<td_api::textEntityTypeTextUrl>(argument);
case MessageEntity::Type::MentionName:
// can't use user_manager, because can be called from a static request
return make_tl_object<td_api::textEntityTypeMentionName>(user_id.get());
return make_tl_object<td_api::textEntityTypeMentionName>(
user_manager == nullptr ? user_id.get()
: user_manager->get_user_id_object(user_id, "textEntityTypeMentionName"));
case MessageEntity::Type::Cashtag:
return make_tl_object<td_api::textEntityTypeCashtag>();
case MessageEntity::Type::PhoneNumber:
@ -187,11 +189,12 @@ tl_object_ptr<td_api::TextEntityType> MessageEntity::get_text_entity_type_object
}
}
tl_object_ptr<td_api::textEntity> MessageEntity::get_text_entity_object() const {
return make_tl_object<td_api::textEntity>(offset, length, get_text_entity_type_object());
tl_object_ptr<td_api::textEntity> MessageEntity::get_text_entity_object(const UserManager *user_manager) const {
return make_tl_object<td_api::textEntity>(offset, length, get_text_entity_type_object(user_manager));
}
vector<tl_object_ptr<td_api::textEntity>> get_text_entities_object(const vector<MessageEntity> &entities,
vector<tl_object_ptr<td_api::textEntity>> get_text_entities_object(const UserManager *user_manager,
const vector<MessageEntity> &entities,
bool skip_bot_commands, int32 max_media_timestamp) {
vector<tl_object_ptr<td_api::textEntity>> result;
result.reserve(entities.size());
@ -203,7 +206,7 @@ vector<tl_object_ptr<td_api::textEntity>> get_text_entities_object(const vector<
if (entity.type == MessageEntity::Type::MediaTimestamp && max_media_timestamp < entity.media_timestamp) {
continue;
}
auto entity_object = entity.get_text_entity_object();
auto entity_object = entity.get_text_entity_object(user_manager);
if (entity_object->type_ != nullptr) {
result.push_back(std::move(entity_object));
}
@ -216,10 +219,11 @@ StringBuilder &operator<<(StringBuilder &string_builder, const FormattedText &te
return string_builder << '"' << text.text << "\" with entities " << text.entities;
}
td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const FormattedText &text, bool skip_bot_commands,
td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const UserManager *user_manager,
const FormattedText &text, bool skip_bot_commands,
int32 max_media_timestamp) {
return td_api::make_object<td_api::formattedText>(
text.text, get_text_entities_object(text.entities, skip_bot_commands, max_media_timestamp));
text.text, get_text_entities_object(user_manager, text.entities, skip_bot_commands, max_media_timestamp));
}
static bool is_word_character(uint32 code) {

View File

@ -81,7 +81,7 @@ class MessageEntity {
CHECK(type == Type::CustomEmoji);
}
tl_object_ptr<td_api::textEntity> get_text_entity_object() const;
tl_object_ptr<td_api::textEntity> get_text_entity_object(const UserManager *user_manager) const;
bool operator==(const MessageEntity &other) const {
return offset == other.offset && length == other.length && type == other.type &&
@ -112,7 +112,7 @@ class MessageEntity {
void parse(ParserT &parser);
private:
tl_object_ptr<td_api::TextEntityType> get_text_entity_type_object() const;
tl_object_ptr<td_api::TextEntityType> get_text_entity_type_object(const UserManager *user_manager) const;
static int get_type_priority(Type type);
};
@ -160,10 +160,12 @@ Result<vector<MessageEntity>> get_message_entities(const UserManager *user_manag
vector<tl_object_ptr<td_api::textEntity>> &&input_entities,
bool allow_all = false);
vector<tl_object_ptr<td_api::textEntity>> get_text_entities_object(const vector<MessageEntity> &entities,
vector<tl_object_ptr<td_api::textEntity>> get_text_entities_object(const UserManager *user_manager,
const vector<MessageEntity> &entities,
bool skip_bot_commands, int32 max_media_timestamp);
td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const FormattedText &text, bool skip_bot_commands,
td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const UserManager *user_manager,
const FormattedText &text, bool skip_bot_commands,
int32 max_media_timestamp);
void remove_premium_custom_emoji_entities(const Td *td, vector<MessageEntity> &entities, bool remove_unknown);

View File

@ -123,10 +123,10 @@ td_api::object_ptr<td_api::InputMessageReplyTo> MessageInputReplyTo::get_input_m
if (dialog_id_ != DialogId()) {
return td_api::make_object<td_api::inputMessageReplyToExternalMessage>(
td->dialog_manager_->get_chat_id_object(dialog_id_, "inputMessageReplyToExternalMessage"), message_id_.get(),
quote_.get_input_text_quote_object());
quote_.get_input_text_quote_object(td->user_manager_.get()));
}
return td_api::make_object<td_api::inputMessageReplyToMessage>(message_id_.get(),
quote_.get_input_text_quote_object());
return td_api::make_object<td_api::inputMessageReplyToMessage>(
message_id_.get(), quote_.get_input_text_quote_object(td->user_manager_.get()));
}
MessageId MessageInputReplyTo::get_same_chat_reply_to_message_id() const {

View File

@ -121,19 +121,22 @@ void MessageQuote::update_input_reply_to_message(Td *td,
}
// only for draft messages
td_api::object_ptr<td_api::inputTextQuote> MessageQuote::get_input_text_quote_object() const {
td_api::object_ptr<td_api::inputTextQuote> MessageQuote::get_input_text_quote_object(
const UserManager *user_manager) const {
if (is_empty()) {
return nullptr;
}
CHECK(is_manual_);
return td_api::make_object<td_api::inputTextQuote>(get_formatted_text_object(text_, true, -1), position_);
return td_api::make_object<td_api::inputTextQuote>(get_formatted_text_object(user_manager, text_, true, -1),
position_);
}
td_api::object_ptr<td_api::textQuote> MessageQuote::get_text_quote_object() const {
td_api::object_ptr<td_api::textQuote> MessageQuote::get_text_quote_object(const UserManager *user_manager) const {
if (is_empty()) {
return nullptr;
}
return td_api::make_object<td_api::textQuote>(get_formatted_text_object(text_, true, -1), position_, is_manual_);
return td_api::make_object<td_api::textQuote>(get_formatted_text_object(user_manager, text_, true, -1), position_,
is_manual_);
}
bool operator==(const MessageQuote &lhs, const MessageQuote &rhs) {

View File

@ -65,9 +65,9 @@ class MessageQuote {
void update_input_reply_to_message(Td *td, telegram_api::inputReplyToMessage *input_reply_to_message) const;
td_api::object_ptr<td_api::inputTextQuote> get_input_text_quote_object() const;
td_api::object_ptr<td_api::inputTextQuote> get_input_text_quote_object(const UserManager *user_manager) const;
td_api::object_ptr<td_api::textQuote> get_text_quote_object() const;
td_api::object_ptr<td_api::textQuote> get_text_quote_object(const UserManager *user_manager) const;
template <class StorerT>
void store(StorerT &storer) const;

View File

@ -6546,7 +6546,7 @@ td_api::object_ptr<td_api::factCheck> MessagesManager::get_message_fact_check_ob
if (m->fact_check == nullptr) {
return nullptr;
}
return m->fact_check->get_fact_check_object();
return m->fact_check->get_fact_check_object(td_->user_manager_.get());
}
vector<td_api::object_ptr<td_api::unreadReaction>> MessagesManager::get_unread_reactions_object(
@ -13521,7 +13521,7 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
reactions->fix_chosen_reaction();
reactions->fix_my_recent_chooser_dialog_id(my_dialog_id);
}
auto fact_check = FactCheck::get_fact_check(td, std::move(message_info.fact_check), is_bot);
auto fact_check = FactCheck::get_fact_check(td->user_manager_.get(), std::move(message_info.fact_check), is_bot);
bool has_forward_info = message_info.forward_header != nullptr;
bool noforwards = message_info.noforwards;
@ -19029,7 +19029,7 @@ void MessagesManager::on_get_message_fact_checks(
if (m == nullptr) {
continue;
}
auto fact_check = FactCheck::get_fact_check(td_, std::move(fact_checks[i]), false);
auto fact_check = FactCheck::get_fact_check(td_->user_manager_.get(), std::move(fact_checks[i]), false);
update_message_fact_check(d, m, std::move(fact_check), true);
}
}

View File

@ -434,7 +434,7 @@ void PollManager::remove_unallowed_entities(FormattedText &text) {
}
td_api::object_ptr<td_api::pollOption> PollManager::get_poll_option_object(const PollOption &poll_option) {
return td_api::make_object<td_api::pollOption>(get_formatted_text_object(poll_option.text_, true, -1),
return td_api::make_object<td_api::pollOption>(get_formatted_text_object(nullptr, poll_option.text_, true, -1),
poll_option.voter_count_, 0, poll_option.is_chosen_, false);
}
@ -563,7 +563,7 @@ td_api::object_ptr<td_api::poll> PollManager::get_poll_object(PollId poll_id, co
voter_count_diff = -1;
}
poll_options.push_back(td_api::make_object<td_api::pollOption>(
get_formatted_text_object(poll_option.text_, true, -1),
get_formatted_text_object(nullptr, poll_option.text_, true, -1),
poll_option.voter_count_ - static_cast<int32>(poll_option.is_chosen_), 0, false, is_being_chosen));
}
}
@ -607,7 +607,7 @@ td_api::object_ptr<td_api::poll> PollManager::get_poll_object(PollId poll_id, co
auto correct_option_id = is_local_poll_id(poll_id) ? -1 : poll->correct_option_id_;
poll_type = td_api::make_object<td_api::pollTypeQuiz>(
correct_option_id,
get_formatted_text_object(is_local_poll_id(poll_id) ? FormattedText() : poll->explanation_, true, -1));
get_formatted_text_object(nullptr, is_local_poll_id(poll_id) ? FormattedText() : poll->explanation_, true, -1));
} else {
poll_type = td_api::make_object<td_api::pollTypeRegular>(poll->allow_multiple_answers_);
}
@ -637,9 +637,10 @@ td_api::object_ptr<td_api::poll> PollManager::get_poll_object(PollId poll_id, co
recent_voters.push_back(std::move(recent_voter));
}
}
return td_api::make_object<td_api::poll>(
poll_id.get(), get_formatted_text_object(poll->question_, true, -1), std::move(poll_options), total_voter_count,
std::move(recent_voters), poll->is_anonymous_, std::move(poll_type), open_period, close_date, poll->is_closed_);
return td_api::make_object<td_api::poll>(poll_id.get(), get_formatted_text_object(nullptr, poll->question_, true, -1),
std::move(poll_options), total_voter_count, std::move(recent_voters),
poll->is_anonymous_, std::move(poll_type), open_period, close_date,
poll->is_closed_);
}
telegram_api::object_ptr<telegram_api::pollAnswer> PollManager::get_input_poll_option(const PollOption &poll_option) {

View File

@ -333,9 +333,10 @@ class GetPremiumPromoQuery final : public Td::ResultHandler {
}
auto period_options = get_premium_gift_options(std::move(promo->period_options_));
promise_.set_value(td_api::make_object<td_api::premiumState>(
get_formatted_text_object(state, true, 0), get_premium_state_payment_options_object(period_options),
std::move(animations), std::move(business_animations)));
promise_.set_value(
td_api::make_object<td_api::premiumState>(get_formatted_text_object(td_->user_manager_.get(), state, true, 0),
get_premium_state_payment_options_object(period_options),
std::move(animations), std::move(business_animations)));
}
void on_error(Status status) final {

View File

@ -309,7 +309,8 @@ td_api::object_ptr<td_api::messageReplyToMessage> RepliedMessageInfo::get_messag
}
}
return td_api::make_object<td_api::messageReplyToMessage>(chat_id, message_id_.get(), quote_.get_text_quote_object(),
return td_api::make_object<td_api::messageReplyToMessage>(chat_id, message_id_.get(),
quote_.get_text_quote_object(td->user_manager_.get()),
std::move(origin), origin_date_, std::move(content));
}

View File

@ -3455,7 +3455,7 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
can_get_interactions, has_expired_viewers, std::move(repost_info), std::move(interaction_info),
story->chosen_reaction_type_.get_reaction_type_object(), std::move(privacy_settings),
get_story_content_object(td_, content), std::move(story_areas),
get_formatted_text_object(*caption, true, get_story_content_duration(td_, content)));
get_formatted_text_object(td_->user_manager_.get(), *caption, true, get_story_content_duration(td_, content)));
}
td_api::object_ptr<td_api::stories> StoryManager::get_stories_object(int32 total_count,

View File

@ -30,7 +30,7 @@ static td_api::object_ptr<td_api::userSupportInfo> get_user_support_info_object(
result->author_ = std::move(info->author_);
result->date_ = info->date_;
}
result->message_ = get_formatted_text_object(message, true, 0);
result->message_ = get_formatted_text_object(td->user_manager_.get(), message, true, 0);
return result;
}

View File

@ -9847,7 +9847,7 @@ td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getTextEn
}
auto text_entities = find_entities(request.text_, false, false);
return make_tl_object<td_api::textEntities>(
get_text_entities_object(text_entities, false, std::numeric_limits<int32>::max()));
get_text_entities_object(nullptr, text_entities, false, std::numeric_limits<int32>::max()));
}
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::parseTextEntities &request) {
@ -9885,7 +9885,7 @@ td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::parseTextEntiti
}
return make_tl_object<td_api::formattedText>(std::move(request.text_),
get_text_entities_object(r_entities.ok(), false, -1));
get_text_entities_object(nullptr, r_entities.ok(), false, -1));
}
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::parseMarkdown &request) {
@ -9905,7 +9905,7 @@ td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::parseMarkdown &
auto parsed_text = parse_markdown_v3({std::move(request.text_->text_), std::move(entities)});
fix_formatted_text(parsed_text.text, parsed_text.entities, true, true, true, true, true).ensure();
return get_formatted_text_object(parsed_text, false, std::numeric_limits<int32>::max());
return get_formatted_text_object(nullptr, parsed_text, false, std::numeric_limits<int32>::max());
}
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getOption &request) {
@ -9930,8 +9930,8 @@ td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::getMarkdownText
return make_error(400, status.message());
}
return get_formatted_text_object(get_markdown_v3({std::move(request.text_->text_), std::move(entities)}), false,
std::numeric_limits<int32>::max());
return get_formatted_text_object(nullptr, get_markdown_v3({std::move(request.text_->text_), std::move(entities)}),
false, std::numeric_limits<int32>::max());
}
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::searchStringsByPrefix &request) {

View File

@ -40,8 +40,8 @@ class TermsOfService {
return nullptr;
}
return td_api::make_object<td_api::termsOfService>(get_formatted_text_object(text_, true, -1), min_user_age_,
show_popup_);
return td_api::make_object<td_api::termsOfService>(get_formatted_text_object(nullptr, text_, true, -1),
min_user_age_, show_popup_);
}
template <class StorerT>

View File

@ -129,7 +129,8 @@ void TranslationManager::on_get_translated_texts(vector<telegram_api::object_ptr
}
auto formatted_text = get_formatted_text(td_->user_manager_.get(), std::move(texts[0]), max_media_timestamp == -1,
true, "on_get_translated_texts");
promise.set_value(get_formatted_text_object(formatted_text, skip_bot_commands, max_media_timestamp));
promise.set_value(
get_formatted_text_object(td_->user_manager_.get(), formatted_text, skip_bot_commands, max_media_timestamp));
}
} // namespace td

View File

@ -7955,7 +7955,7 @@ td_api::object_ptr<td_api::userFullInfo> UserManager::get_user_full_info_object(
return false;
});
}
bio_object = get_formatted_text_object(bio, true, 0);
bio_object = get_formatted_text_object(this, bio, true, 0);
}
auto voice_messages_forbidden = is_premium ? user_full->voice_messages_forbidden : false;
auto block_list_id = BlockListId(user_full->is_blocked, user_full->is_blocked_for_stories);

View File

@ -1821,7 +1821,8 @@ td_api::object_ptr<td_api::linkPreview> WebPagesManager::get_link_preview_object
}();
return td_api::make_object<td_api::linkPreview>(
web_page->url_, web_page->display_url_, web_page->site_name_, web_page->title_,
get_formatted_text_object(description, true, duration == 0 ? std::numeric_limits<int32>::max() : duration),
get_formatted_text_object(td_->user_manager_.get(), description, true,
duration == 0 ? std::numeric_limits<int32>::max() : duration),
get_link_preview_type_object(web_page), web_page->has_large_media_, show_large_media, skip_confirmation,
invert_media, instant_view_version);
}