diff --git a/td/telegram/Photo.cpp b/td/telegram/Photo.cpp index 3da732016..f41d24f55 100644 --- a/td/telegram/Photo.cpp +++ b/td/telegram/Photo.cpp @@ -290,12 +290,12 @@ Variant get_photo_size(FileManager *file_manager, FileType fi std::string upload_file_reference, DialogId owner_dialog_id, tl_object_ptr &&size_ptr, bool is_webp, bool is_png) { + CHECK(size_ptr != nullptr); + tl_object_ptr location_ptr; string type; - PhotoSize res; BufferSlice content; - switch (size_ptr->get_id()) { case telegram_api::photoSizeEmpty::ID: return std::move(res); diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index a001d562f..d2c94c733 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1622,19 +1622,22 @@ int64 StickersManager::on_get_sticker_set(tl_object_ptrflags_ & telegram_api::stickerSet::OFFICIAL_MASK) != 0; bool is_masks = (set->flags_ & telegram_api::stickerSet::MASKS_MASK) != 0; - auto photo_size = get_photo_size(td_->file_manager_.get(), FileType::Thumbnail, 0, 0, "", DialogId(), - std::move(set->thumb_), true, false); PhotoSize thumbnail; - if (photo_size.get_offset() == 0) { - thumbnail = std::move(photo_size.get<0>()); - } else { - LOG(ERROR) << "Receive minithumbnail for a sticker set " << set_id; + if (set->thumb_ != nullptr) { + auto photo_size = get_photo_size(td_->file_manager_.get(), FileType::Thumbnail, 0, 0, "", DialogId(), + std::move(set->thumb_), true, false); + if (photo_size.get_offset() == 0) { + thumbnail = std::move(photo_size.get<0>()); + } else { + LOG(ERROR) << "Receive minithumbnail for a sticker set " << set_id; + } } if (!s->is_inited) { s->is_inited = true; s->title = std::move(set->title_); s->short_name = std::move(set->short_name_); s->thumbnail = std::move(thumbnail); + s->is_thumbnail_reloaded = true; s->sticker_count = set->count_; s->hash = set->hash_; s->is_official = is_official; @@ -1672,6 +1675,10 @@ int64 StickersManager::on_get_sticker_set(tl_object_ptrthumbnail = std::move(thumbnail); s->is_changed = true; } + if (!s->is_thumbnail_reloaded) { + s->is_thumbnail_reloaded = true; + s->is_changed = true; + } if (s->sticker_count != set->count_ || s->hash != set->hash_) { s->is_loaded = false; @@ -2770,6 +2777,9 @@ void StickersManager::on_load_sticker_set_from_database(int64 sticker_set_id, bo } status.ensure(); } + if (!sticker_set->is_thumbnail_reloaded) { + reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto()); + } if (with_stickers && old_sticker_count < 5 && old_sticker_count < sticker_set->sticker_ids.size()) { sticker_set->is_changed = true; diff --git a/td/telegram/StickersManager.h b/td/telegram/StickersManager.h index 0afa07a90..f870ccc49 100644 --- a/td/telegram/StickersManager.h +++ b/td/telegram/StickersManager.h @@ -287,6 +287,7 @@ class StickersManager : public Actor { bool is_official = false; bool is_masks = false; bool is_viewed = true; + bool is_thumbnail_reloaded = false; bool is_changed = true; vector load_requests; diff --git a/td/telegram/StickersManager.hpp b/td/telegram/StickersManager.hpp index d19108d4b..66ad9185a 100644 --- a/td/telegram/StickersManager.hpp +++ b/td/telegram/StickersManager.hpp @@ -122,6 +122,7 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with STORE_FLAG(sticker_set->is_viewed); STORE_FLAG(has_expires_at); STORE_FLAG(has_thumbnail); + STORE_FLAG(sticker_set->is_thumbnail_reloaded); END_STORE_FLAGS(); store(sticker_set->id, storer); store(sticker_set->access_hash, storer); @@ -177,6 +178,7 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser PARSE_FLAG(sticker_set->is_viewed); PARSE_FLAG(has_expires_at); PARSE_FLAG(has_thumbnail); + PARSE_FLAG(sticker_set->is_thumbnail_reloaded); END_PARSE_FLAGS(); int64 sticker_set_id; int64 access_hash;