Simplify get_photo_object.
GitOrigin-RevId: 08c8fb7fe4eadb4bff56198d5834c708e032979b
This commit is contained in:
parent
82fdcd279c
commit
9a92f6d571
@ -13599,7 +13599,7 @@ tl_object_ptr<td_api::userFullInfo> ContactsManager::get_user_full_info_object(U
|
||||
CHECK(user_full != nullptr);
|
||||
bool is_bot = is_user_bot(user_id);
|
||||
return make_tl_object<td_api::userFullInfo>(
|
||||
get_user_profile_photo_object(td_->file_manager_.get(), &user_full->photo), user_full->is_blocked,
|
||||
get_user_profile_photo_object(td_->file_manager_.get(), user_full->photo), user_full->is_blocked,
|
||||
user_full->can_be_called, user_full->has_private_calls, user_full->need_phone_number_privacy_exception,
|
||||
is_bot ? string() : user_full->about, is_bot ? user_full->about : string(), user_full->common_chat_count,
|
||||
is_bot ? get_bot_info_object(user_id) : nullptr);
|
||||
@ -13644,7 +13644,7 @@ tl_object_ptr<td_api::basicGroupFullInfo> ContactsManager::get_basic_group_full_
|
||||
const ChatFull *chat_full) const {
|
||||
CHECK(chat_full != nullptr);
|
||||
return make_tl_object<td_api::basicGroupFullInfo>(
|
||||
get_chat_photo_full_info_object(td_->file_manager_.get(), &chat_full->photo), chat_full->description,
|
||||
get_chat_photo_full_info_object(td_->file_manager_.get(), chat_full->photo), chat_full->description,
|
||||
get_user_id_object(chat_full->creator_user_id, "basicGroupFullInfo"),
|
||||
transform(chat_full->participants,
|
||||
[this](const DialogParticipant &chat_participant) { return get_chat_member_object(chat_participant); }),
|
||||
@ -13689,7 +13689,7 @@ tl_object_ptr<td_api::supergroupFullInfo> ContactsManager::get_supergroup_full_i
|
||||
slow_mode_delay_expires_in = max(channel_full->slow_mode_next_send_date - G()->server_time(), 1e-3);
|
||||
}
|
||||
return td_api::make_object<td_api::supergroupFullInfo>(
|
||||
get_chat_photo_full_info_object(td_->file_manager_.get(), &channel_full->photo), channel_full->description,
|
||||
get_chat_photo_full_info_object(td_->file_manager_.get(), channel_full->photo), channel_full->description,
|
||||
channel_full->participant_count, channel_full->administrator_count, channel_full->restricted_count,
|
||||
channel_full->banned_count, DialogId(channel_full->linked_channel_id).get(), channel_full->slow_mode_delay,
|
||||
slow_mode_delay_expires_in, channel_full->can_get_participants, channel_full->can_set_username,
|
||||
|
@ -94,7 +94,7 @@ const FormattedText &Game::get_text() const {
|
||||
tl_object_ptr<td_api::game> Game::get_game_object(Td *td) const {
|
||||
return make_tl_object<td_api::game>(
|
||||
id_, short_name_, title_, get_formatted_text_object(text_), description_,
|
||||
get_photo_object(td->file_manager_.get(), &photo_),
|
||||
get_photo_object(td->file_manager_.get(), photo_),
|
||||
td->animations_manager_->get_animation_object(animation_file_id_, "get_game_object"));
|
||||
}
|
||||
|
||||
|
@ -1306,7 +1306,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
|
||||
LOG(ERROR) << "Receive empty cached photo in the result of inline query";
|
||||
break;
|
||||
}
|
||||
photo->photo_ = get_photo_object(td_->file_manager_.get(), &p);
|
||||
photo->photo_ = get_photo_object(td_->file_manager_.get(), p);
|
||||
photo->title_ = std::move(result->title_);
|
||||
photo->description_ = std::move(result->description_);
|
||||
|
||||
@ -1431,7 +1431,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
|
||||
}
|
||||
new_photo.photos.push_back(std::move(photo_size));
|
||||
|
||||
photo->photo_ = get_photo_object(td_->file_manager_.get(), &new_photo);
|
||||
photo->photo_ = get_photo_object(td_->file_manager_.get(), new_photo);
|
||||
photo->title_ = std::move(result->title_);
|
||||
photo->description_ = std::move(result->description_);
|
||||
|
||||
|
@ -4379,7 +4379,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
case MessageContentType::Invoice: {
|
||||
const MessageInvoice *m = static_cast<const MessageInvoice *>(content);
|
||||
return make_tl_object<td_api::messageInvoice>(
|
||||
m->title, m->description, get_photo_object(td->file_manager_.get(), &m->photo), m->invoice.currency,
|
||||
m->title, m->description, get_photo_object(td->file_manager_.get(), m->photo), m->invoice.currency,
|
||||
m->total_amount, m->start_parameter, m->invoice.is_test, m->invoice.need_shipping_address,
|
||||
m->receipt_message_id.get());
|
||||
}
|
||||
@ -4395,7 +4395,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
}
|
||||
case MessageContentType::Photo: {
|
||||
const MessagePhoto *m = static_cast<const MessagePhoto *>(content);
|
||||
return make_tl_object<td_api::messagePhoto>(get_photo_object(td->file_manager_.get(), &m->photo),
|
||||
return make_tl_object<td_api::messagePhoto>(get_photo_object(td->file_manager_.get(), m->photo),
|
||||
get_formatted_text_object(m->caption), is_content_secret);
|
||||
}
|
||||
case MessageContentType::Sticker: {
|
||||
@ -4440,7 +4440,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
case MessageContentType::ChatChangePhoto: {
|
||||
const MessageChatChangePhoto *m = static_cast<const MessageChatChangePhoto *>(content);
|
||||
return make_tl_object<td_api::messageChatChangePhoto>(
|
||||
get_chat_photo_full_info_object(td->file_manager_.get(), &m->photo));
|
||||
get_chat_photo_full_info_object(td->file_manager_.get(), m->photo));
|
||||
}
|
||||
case MessageContentType::ChatDeletePhoto:
|
||||
return make_tl_object<td_api::messageChatDeletePhoto>();
|
||||
|
@ -27864,8 +27864,8 @@ tl_object_ptr<td_api::ChatEventAction> MessagesManager::get_chat_event_action_ob
|
||||
auto file_manager = td_->file_manager_.get();
|
||||
auto old_photo = get_photo(file_manager, std::move(action->prev_photo_), DialogId(channel_id));
|
||||
auto new_photo = get_photo(file_manager, std::move(action->new_photo_), DialogId(channel_id));
|
||||
return make_tl_object<td_api::chatEventPhotoChanged>(get_chat_photo_full_info_object(file_manager, &old_photo),
|
||||
get_chat_photo_full_info_object(file_manager, &new_photo));
|
||||
return make_tl_object<td_api::chatEventPhotoChanged>(get_chat_photo_full_info_object(file_manager, old_photo),
|
||||
get_chat_photo_full_info_object(file_manager, new_photo));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionDefaultBannedRights::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionDefaultBannedRights>(action_ptr);
|
||||
|
@ -255,8 +255,8 @@ class NotificationTypePushMessage : public NotificationType {
|
||||
case 'P':
|
||||
if (key == "MESSAGE_PHOTO") {
|
||||
auto file_manager = G()->td().get_actor_unsafe()->file_manager_.get();
|
||||
return td_api::make_object<td_api::pushMessageContentPhoto>(get_photo_object(file_manager, &photo), arg,
|
||||
false, is_pinned);
|
||||
return td_api::make_object<td_api::pushMessageContentPhoto>(get_photo_object(file_manager, photo), arg, false,
|
||||
is_pinned);
|
||||
}
|
||||
if (key == "MESSAGE_PHOTOS") {
|
||||
return td_api::make_object<td_api::pushMessageContentMediaAlbum>(to_integer<int32>(arg), true, false);
|
||||
|
@ -644,32 +644,31 @@ Photo get_web_document_photo(FileManager *file_manager, tl_object_ptr<telegram_a
|
||||
return photo;
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::photo> get_photo_object(FileManager *file_manager, const Photo *photo) {
|
||||
if (photo == nullptr || photo->is_empty()) {
|
||||
tl_object_ptr<td_api::photo> get_photo_object(FileManager *file_manager, const Photo &photo) {
|
||||
if (photo.is_empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return td_api::make_object<td_api::photo>(photo->has_stickers, get_minithumbnail_object(photo->minithumbnail),
|
||||
get_photo_sizes_object(file_manager, photo->photos));
|
||||
return td_api::make_object<td_api::photo>(photo.has_stickers, get_minithumbnail_object(photo.minithumbnail),
|
||||
get_photo_sizes_object(file_manager, photo.photos));
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::userProfilePhoto> get_user_profile_photo_object(FileManager *file_manager, const Photo *photo) {
|
||||
if (photo == nullptr || photo->is_empty()) {
|
||||
tl_object_ptr<td_api::userProfilePhoto> get_user_profile_photo_object(FileManager *file_manager, const Photo &photo) {
|
||||
if (photo.is_empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return td_api::make_object<td_api::userProfilePhoto>(photo->id.get(), photo->date,
|
||||
get_photo_sizes_object(file_manager, photo->photos));
|
||||
return td_api::make_object<td_api::userProfilePhoto>(photo.id.get(), photo.date,
|
||||
get_photo_sizes_object(file_manager, photo.photos));
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::chatPhotoFullInfo> get_chat_photo_full_info_object(FileManager *file_manager,
|
||||
const Photo *photo) {
|
||||
if (photo == nullptr || photo->is_empty()) {
|
||||
const Photo &photo) {
|
||||
if (photo.is_empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return td_api::make_object<td_api::chatPhotoFullInfo>(photo->date,
|
||||
get_photo_sizes_object(file_manager, photo->photos));
|
||||
return td_api::make_object<td_api::chatPhotoFullInfo>(photo.date, get_photo_sizes_object(file_manager, photo.photos));
|
||||
}
|
||||
|
||||
void photo_delete_thumbnail(Photo &photo) {
|
||||
|
@ -124,9 +124,9 @@ Photo get_encrypted_file_photo(FileManager *file_manager, tl_object_ptr<telegram
|
||||
tl_object_ptr<secret_api::decryptedMessageMediaPhoto> &&photo, DialogId owner_dialog_id);
|
||||
Photo get_web_document_photo(FileManager *file_manager, tl_object_ptr<telegram_api::WebDocument> web_document,
|
||||
DialogId owner_dialog_id);
|
||||
tl_object_ptr<td_api::photo> get_photo_object(FileManager *file_manager, const Photo *photo);
|
||||
tl_object_ptr<td_api::userProfilePhoto> get_user_profile_photo_object(FileManager *file_manager, const Photo *photo);
|
||||
tl_object_ptr<td_api::chatPhotoFullInfo> get_chat_photo_full_info_object(FileManager *file_manager, const Photo *photo);
|
||||
tl_object_ptr<td_api::photo> get_photo_object(FileManager *file_manager, const Photo &photo);
|
||||
tl_object_ptr<td_api::userProfilePhoto> get_user_profile_photo_object(FileManager *file_manager, const Photo &photo);
|
||||
tl_object_ptr<td_api::chatPhotoFullInfo> get_chat_photo_full_info_object(FileManager *file_manager, const Photo &photo);
|
||||
|
||||
void photo_delete_thumbnail(Photo &photo);
|
||||
|
||||
|
@ -2246,7 +2246,8 @@ class GetUserProfilePhotosRequest : public RequestActor<> {
|
||||
void do_send_result() override {
|
||||
// TODO create function get_user_profile_photos_object
|
||||
auto result = transform(photos.second, [file_manager = td->file_manager_.get()](const Photo *photo) {
|
||||
return get_user_profile_photo_object(file_manager, photo);
|
||||
CHECK(photo != nullptr);
|
||||
return get_user_profile_photo_object(file_manager, *photo);
|
||||
});
|
||||
|
||||
send_result(make_tl_object<td_api::userProfilePhotos>(photos.first, std::move(result)));
|
||||
|
@ -1048,7 +1048,7 @@ class WebPageBlockPhoto : public WebPageBlock {
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::PageBlock> get_page_block_object(Context *context) const override {
|
||||
return make_tl_object<td_api::pageBlockPhoto>(get_photo_object(context->td_->file_manager_.get(), &photo),
|
||||
return make_tl_object<td_api::pageBlockPhoto>(get_photo_object(context->td_->file_manager_.get(), photo),
|
||||
caption.get_page_block_caption_object(context), url);
|
||||
}
|
||||
|
||||
@ -1211,7 +1211,7 @@ class WebPageBlockEmbedded : public WebPageBlock {
|
||||
|
||||
td_api::object_ptr<td_api::PageBlock> get_page_block_object(Context *context) const override {
|
||||
return make_tl_object<td_api::pageBlockEmbedded>(
|
||||
url, html, get_photo_object(context->td_->file_manager_.get(), &poster_photo), dimensions.width,
|
||||
url, html, get_photo_object(context->td_->file_manager_.get(), poster_photo), dimensions.width,
|
||||
dimensions.height, caption.get_page_block_caption_object(context), is_full_width, allow_scrolling);
|
||||
}
|
||||
|
||||
@ -1280,7 +1280,7 @@ class WebPageBlockEmbeddedPost : public WebPageBlock {
|
||||
|
||||
td_api::object_ptr<td_api::PageBlock> get_page_block_object(Context *context) const override {
|
||||
return make_tl_object<td_api::pageBlockEmbeddedPost>(
|
||||
url, author, get_photo_object(context->td_->file_manager_.get(), &author_photo), date,
|
||||
url, author, get_photo_object(context->td_->file_manager_.get(), author_photo), date,
|
||||
get_page_block_objects(page_blocks, context), caption.get_page_block_caption_object(context));
|
||||
}
|
||||
|
||||
@ -1632,7 +1632,7 @@ class WebPageBlockRelatedArticles : public WebPageBlock {
|
||||
auto related_article_objects = transform(related_articles, [context](const RelatedArticle &article) {
|
||||
return td_api::make_object<td_api::pageBlockRelatedArticle>(
|
||||
article.url, article.title, article.description,
|
||||
get_photo_object(context->td_->file_manager_.get(), &article.photo), article.author, article.published_date);
|
||||
get_photo_object(context->td_->file_manager_.get(), article.photo), article.author, article.published_date);
|
||||
});
|
||||
return make_tl_object<td_api::pageBlockRelatedArticles>(header.get_rich_text_object(context),
|
||||
std::move(related_article_objects));
|
||||
|
@ -1252,7 +1252,7 @@ tl_object_ptr<td_api::webPage> WebPagesManager::get_web_page_object(WebPageId we
|
||||
|
||||
return make_tl_object<td_api::webPage>(
|
||||
web_page->url, web_page->display_url, web_page->type, web_page->site_name, web_page->title,
|
||||
get_formatted_text_object(description), get_photo_object(td_->file_manager_.get(), &web_page->photo),
|
||||
get_formatted_text_object(description), get_photo_object(td_->file_manager_.get(), web_page->photo),
|
||||
web_page->embed_url, web_page->embed_type, web_page->embed_dimensions.width, web_page->embed_dimensions.height,
|
||||
web_page->duration, web_page->author,
|
||||
web_page->document.type == Document::Type::Animation
|
||||
|
Loading…
Reference in New Issue
Block a user