Add Photo.is_empty().
GitOrigin-RevId: 6dd6aeaaaa703f9cd865598d52b97eb64523fea0
This commit is contained in:
parent
ef04c17a89
commit
4acf82c506
@ -3241,7 +3241,7 @@ template <class StorerT>
|
||||
void ContactsManager::UserFull::store(StorerT &storer) const {
|
||||
using td::store;
|
||||
bool has_about = !about.empty();
|
||||
bool has_photo = photo.id != -2;
|
||||
bool has_photo = !photo.is_empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_about);
|
||||
STORE_FLAG(is_blocked);
|
||||
@ -8911,7 +8911,7 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
|
||||
}
|
||||
|
||||
user->photo = get_photo(td_->file_manager_.get(), std::move(user_full->profile_photo_), DialogId());
|
||||
if (user->photo.id == -2) {
|
||||
if (user->photo.is_empty()) {
|
||||
drop_user_photos(user_id, true, false, "on_get_user_full");
|
||||
} else {
|
||||
add_user_photo_id(u, user_id, user->photo.id, photo_get_file_ids(user->photo));
|
||||
@ -8990,7 +8990,7 @@ void ContactsManager::on_get_user_photos(UserId user_id, int32 offset, int32 lim
|
||||
|
||||
for (auto &photo : photos) {
|
||||
auto user_photo = get_photo(td_->file_manager_.get(), std::move(photo), DialogId());
|
||||
if (user_photo.id == -2) {
|
||||
if (user_photo.is_empty()) {
|
||||
LOG(ERROR) << "Receive empty profile photo in getUserPhotos request for " << user_id << " with offset " << offset
|
||||
<< " and limit " << limit << ". Receive " << photo_count << " photos out of " << total_count
|
||||
<< " photos";
|
||||
@ -9750,7 +9750,7 @@ void ContactsManager::drop_user_photos(UserId user_id, bool is_empty, bool drop_
|
||||
}
|
||||
|
||||
if (is_empty) {
|
||||
if (user_full->photo.id != -2) {
|
||||
if (!user_full->photo.is_empty()) {
|
||||
user_full->photo = Photo();
|
||||
user_full->is_changed = true;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ Game::Game(Td *td, string title, string description, tl_object_ptr<telegram_api:
|
||||
CHECK(td != nullptr);
|
||||
CHECK(photo != nullptr);
|
||||
photo_ = get_photo(td->file_manager_.get(), std::move(photo), owner_dialog_id);
|
||||
if (photo_.id == -2) {
|
||||
if (photo_.is_empty()) {
|
||||
LOG(ERROR) << "Receive empty photo for game " << title;
|
||||
photo_.id = 0; // to prevent null photo in td_api
|
||||
}
|
||||
|
@ -1300,7 +1300,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
|
||||
auto photo = make_tl_object<td_api::inlineQueryResultPhoto>();
|
||||
photo->id_ = std::move(result->id_);
|
||||
Photo p = get_photo(td_->file_manager_.get(), std::move(result->photo_), DialogId());
|
||||
if (p.id == -2) {
|
||||
if (p.is_empty()) {
|
||||
LOG(ERROR) << "Receive empty cached photo in the result of inline query";
|
||||
break;
|
||||
}
|
||||
|
@ -2129,7 +2129,7 @@ static tl_object_ptr<telegram_api::invoice> get_input_invoice(const Invoice &inv
|
||||
|
||||
static tl_object_ptr<telegram_api::inputWebDocument> get_input_web_document(const FileManager *file_manager,
|
||||
const Photo &photo) {
|
||||
if (photo.id == -2) {
|
||||
if (photo.is_empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -3785,7 +3785,7 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
||||
}
|
||||
|
||||
auto photo = get_photo(td->file_manager_.get(), std::move(message_photo->photo_), owner_dialog_id);
|
||||
if (photo.id == -2) {
|
||||
if (photo.is_empty()) {
|
||||
return make_unique<MessageExpiredPhoto>();
|
||||
}
|
||||
|
||||
@ -4197,7 +4197,7 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
|
||||
case telegram_api::messageActionChatEditPhoto::ID: {
|
||||
auto chat_edit_photo = move_tl_object_as<telegram_api::messageActionChatEditPhoto>(action);
|
||||
auto photo = get_photo(td->file_manager_.get(), std::move(chat_edit_photo->photo_), owner_dialog_id);
|
||||
if (photo.id == -2) {
|
||||
if (photo.is_empty()) {
|
||||
break;
|
||||
}
|
||||
return make_unique<MessageChatChangePhoto>(std::move(photo));
|
||||
|
@ -3425,7 +3425,7 @@ class NotificationManager::AddMessagePushNotificationLogEvent {
|
||||
bool has_sender = sender_user_id_.is_valid();
|
||||
bool has_sender_name = !sender_name_.empty();
|
||||
bool has_arg = !arg_.empty();
|
||||
bool has_photo = photo_.id != -2;
|
||||
bool has_photo = !photo_.is_empty();
|
||||
bool has_document = !document_.empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(contains_mention_);
|
||||
@ -3630,7 +3630,7 @@ class NotificationManager::EditMessagePushNotificationLogEvent {
|
||||
void store(StorerT &storer) const {
|
||||
bool has_message_id = message_id_.is_valid();
|
||||
bool has_arg = !arg_.empty();
|
||||
bool has_photo = photo_.id != -2;
|
||||
bool has_photo = !photo_.is_empty();
|
||||
bool has_document = !document_.empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_message_id);
|
||||
|
@ -267,7 +267,7 @@ vector<FileId> dialog_photo_get_file_ids(const DialogPhoto &dialog_photo) {
|
||||
|
||||
DialogPhoto as_dialog_photo(const Photo &photo) {
|
||||
DialogPhoto result;
|
||||
if (photo.id != -2) {
|
||||
if (!photo.is_empty()) {
|
||||
for (auto &size : photo.photos) {
|
||||
if (size.type == 'a') {
|
||||
result.small_file_id = size.file_id;
|
||||
@ -609,7 +609,7 @@ Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::photo> &&
|
||||
res.date = photo->date_;
|
||||
res.has_stickers = (photo->flags_ & telegram_api::photo::HAS_STICKERS_MASK) != 0;
|
||||
|
||||
if (res.id == -2) {
|
||||
if (res.is_empty()) {
|
||||
LOG(ERROR) << "Receive photo with id " << res.id;
|
||||
res.id = -3;
|
||||
}
|
||||
@ -645,7 +645,7 @@ Photo get_web_document_photo(FileManager *file_manager, tl_object_ptr<telegram_a
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::photo> get_photo_object(FileManager *file_manager, const Photo *photo) {
|
||||
if (photo == nullptr || photo->id == -2) {
|
||||
if (photo == nullptr || photo->is_empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -654,7 +654,7 @@ tl_object_ptr<td_api::photo> get_photo_object(FileManager *file_manager, const P
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::userProfilePhoto> get_user_profile_photo_object(FileManager *file_manager, const Photo *photo) {
|
||||
if (photo == nullptr || photo->id == -2) {
|
||||
if (photo == nullptr || photo->is_empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,10 @@ struct Photo {
|
||||
|
||||
bool has_stickers = false;
|
||||
vector<FileId> sticker_file_ids;
|
||||
|
||||
bool is_empty() const {
|
||||
return id == -2;
|
||||
}
|
||||
};
|
||||
|
||||
Dimensions get_dimensions(int32 width, int32 height);
|
||||
|
@ -369,7 +369,7 @@ class RelatedArticle {
|
||||
using ::td::store;
|
||||
bool has_title = !title.empty();
|
||||
bool has_description = !description.empty();
|
||||
bool has_photo = photo.id != -2;
|
||||
bool has_photo = !photo.is_empty();
|
||||
bool has_author = !author.empty();
|
||||
bool has_date = published_date != 0;
|
||||
BEGIN_STORE_FLAGS();
|
||||
@ -1622,7 +1622,7 @@ class WebPageBlockRelatedArticles : public WebPageBlock {
|
||||
void append_file_ids(const Td *td, vector<FileId> &file_ids) const override {
|
||||
header.append_file_ids(td, file_ids);
|
||||
for (auto &article : related_articles) {
|
||||
if (article.photo.id != -2) {
|
||||
if (!article.photo.is_empty()) {
|
||||
append(file_ids, photo_get_file_ids(article.photo));
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ class WebPagesManager::WebPage {
|
||||
bool has_site_name = !site_name.empty();
|
||||
bool has_title = !title.empty();
|
||||
bool has_description = !description.empty();
|
||||
bool has_photo = photo.id != -2;
|
||||
bool has_photo = !photo.is_empty();
|
||||
bool has_embed = !embed_url.empty();
|
||||
bool has_embed_dimensions = has_embed && embed_dimensions != Dimensions();
|
||||
bool has_duration = duration > 0;
|
||||
@ -1391,14 +1391,14 @@ void WebPagesManager::on_get_web_page_instant_view(WebPage *web_page, tl_object_
|
||||
std::unordered_map<int64, Photo> photos;
|
||||
for (auto &photo_ptr : page->photos_) {
|
||||
Photo photo = get_photo(td_->file_manager_.get(), std::move(photo_ptr), owner_dialog_id);
|
||||
if (photo.id == -2 || photo.id == 0) {
|
||||
if (photo.is_empty() || photo.id == 0) {
|
||||
LOG(ERROR) << "Receive empty photo in web page instant view for " << web_page->url;
|
||||
} else {
|
||||
auto photo_id = photo.id;
|
||||
photos.emplace(photo_id, std::move(photo));
|
||||
}
|
||||
}
|
||||
if (web_page->photo.id != -2 && web_page->photo.id != 0) {
|
||||
if (!web_page->photo.is_empty() && web_page->photo.id != 0) {
|
||||
photos.emplace(web_page->photo.id, web_page->photo);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user