Update layer to 121.

This commit is contained in:
levlam 2020-11-09 23:41:23 +03:00
parent eb80924dad
commit d22dabfdaf
10 changed files with 96 additions and 34 deletions

View File

@ -181,6 +181,7 @@ photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = Phot
photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize; photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize;
photoStrippedSize#e0b0bc2e type:string bytes:bytes = PhotoSize; photoStrippedSize#e0b0bc2e type:string bytes:bytes = PhotoSize;
photoSizeProgressive#5aa86a51 type:string location:FileLocation w:int h:int sizes:Vector<int> = PhotoSize; photoSizeProgressive#5aa86a51 type:string location:FileLocation w:int h:int sizes:Vector<int> = PhotoSize;
photoPathSize#d8214d41 type:string bytes:bytes = PhotoSize;
geoPointEmpty#1117dd5f = GeoPoint; geoPointEmpty#1117dd5f = GeoPoint;
geoPoint#b2a2f663 flags:# long:double lat:double access_hash:long accuracy_radius:flags.0?int = GeoPoint; geoPoint#b2a2f663 flags:# long:double lat:double access_hash:long accuracy_radius:flags.0?int = GeoPoint;

Binary file not shown.

View File

@ -261,11 +261,13 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
if (document_type != Document::Type::VoiceNote) { if (document_type != Document::Type::VoiceNote) {
for (auto &thumb : document->thumbs_) { for (auto &thumb : document->thumbs_) {
auto photo_size = auto photo_size = get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, id, access_hash,
get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, id, access_hash, file_reference, file_reference, DcId::create(dc_id), owner_dialog_id, std::move(thumb),
DcId::create(dc_id), owner_dialog_id, std::move(thumb), thumbnail_format); thumbnail_format, document_type != Document::Type::Sticker);
if (photo_size.get_offset() == 0) { if (photo_size.get_offset() == 0) {
thumbnail = std::move(photo_size.get<0>()); if (!thumbnail.file_id.is_valid()) {
thumbnail = std::move(photo_size.get<0>());
}
} else { } else {
minithumbnail = std::move(photo_size.get<1>()); minithumbnail = std::move(photo_size.get<1>());
} }
@ -429,8 +431,8 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
std::move(mime_type), !is_web); std::move(mime_type), !is_web);
break; break;
case Document::Type::Sticker: case Document::Type::Sticker:
td_->stickers_manager_->create_sticker(file_id, std::move(thumbnail), dimensions, std::move(sticker), td_->stickers_manager_->create_sticker(file_id, std::move(minithumbnail), std::move(thumbnail), dimensions,
is_animated_sticker, load_data_multipromise_ptr); std::move(sticker), is_animated_sticker, load_data_multipromise_ptr);
break; break;
case Document::Type::Video: case Document::Type::Video:
td_->videos_manager_->create_video(file_id, std::move(minithumbnail), std::move(thumbnail), td_->videos_manager_->create_video(file_id, std::move(minithumbnail), std::move(thumbnail),

View File

@ -1638,8 +1638,9 @@ static Result<InputMessageContent> create_input_message_content(
} }
case td_api::inputMessageSticker::ID: { case td_api::inputMessageSticker::ID: {
auto input_sticker = static_cast<td_api::inputMessageSticker *>(input_message_content.get()); auto input_sticker = static_cast<td_api::inputMessageSticker *>(input_message_content.get());
td->stickers_manager_->create_sticker( td->stickers_manager_->create_sticker(file_id, string(), thumbnail,
file_id, thumbnail, get_dimensions(input_sticker->width_, input_sticker->height_), nullptr, false, nullptr); get_dimensions(input_sticker->width_, input_sticker->height_), nullptr,
false, nullptr);
content = make_unique<MessageSticker>(file_id); content = make_unique<MessageSticker>(file_id);
break; break;

View File

@ -358,7 +358,7 @@ PhotoSize get_secret_thumbnail_photo_size(FileManager *file_manager, BufferSlice
Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id, Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id,
int64 access_hash, std::string file_reference, DcId dc_id, int64 access_hash, std::string file_reference, DcId dc_id,
DialogId owner_dialog_id, tl_object_ptr<telegram_api::PhotoSize> &&size_ptr, DialogId owner_dialog_id, tl_object_ptr<telegram_api::PhotoSize> &&size_ptr,
PhotoFormat format) { PhotoFormat format, bool expect_jpeg_minithumbnail) {
CHECK(size_ptr != nullptr); CHECK(size_ptr != nullptr);
tl_object_ptr<telegram_api::fileLocationToBeDeprecated> location; tl_object_ptr<telegram_api::fileLocationToBeDeprecated> location;
@ -393,6 +393,10 @@ Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSo
} }
case telegram_api::photoStrippedSize::ID: { case telegram_api::photoStrippedSize::ID: {
auto size = move_tl_object_as<telegram_api::photoStrippedSize>(size_ptr); auto size = move_tl_object_as<telegram_api::photoStrippedSize>(size_ptr);
if (!expect_jpeg_minithumbnail) {
LOG(ERROR) << "Receive unexpected JPEG minithumbnail";
return std::move(res);
}
return size->bytes_.as_slice().str(); return size->bytes_.as_slice().str();
} }
case telegram_api::photoSizeProgressive::ID: { case telegram_api::photoSizeProgressive::ID: {
@ -413,6 +417,14 @@ Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSo
break; break;
} }
case telegram_api::photoPathSize::ID: {
auto size = move_tl_object_as<telegram_api::photoPathSize>(size_ptr);
if (expect_jpeg_minithumbnail) {
LOG(ERROR) << "Receive unexpected SVG minithumbnail";
return std::move(res);
}
return size->bytes_.as_slice().str();
}
default: default:
UNREACHABLE(); UNREACHABLE();
break; break;
@ -704,7 +716,7 @@ Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::photo> &&
for (auto &size_ptr : photo->sizes_) { for (auto &size_ptr : photo->sizes_) {
auto photo_size = get_photo_size(file_manager, {FileType::Photo, 0}, photo->id_, photo->access_hash_, auto photo_size = get_photo_size(file_manager, {FileType::Photo, 0}, photo->id_, photo->access_hash_,
photo->file_reference_.as_slice().str(), dc_id, owner_dialog_id, photo->file_reference_.as_slice().str(), dc_id, owner_dialog_id,
std::move(size_ptr), PhotoFormat::Jpeg); std::move(size_ptr), PhotoFormat::Jpeg, true);
if (photo_size.get_offset() == 0) { if (photo_size.get_offset() == 0) {
PhotoSize &size = photo_size.get<0>(); PhotoSize &size = photo_size.get<0>();
if (size.type == 0 || size.type == 't' || size.type == 'i' || size.type == 'u' || size.type == 'v') { if (size.type == 0 || size.type == 't' || size.type == 'i' || size.type == 'u' || size.type == 'v') {

View File

@ -113,7 +113,7 @@ PhotoSize get_secret_thumbnail_photo_size(FileManager *file_manager, BufferSlice
Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id, Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id,
int64 access_hash, string file_reference, DcId dc_id, int64 access_hash, string file_reference, DcId dc_id,
DialogId owner_dialog_id, tl_object_ptr<telegram_api::PhotoSize> &&size_ptr, DialogId owner_dialog_id, tl_object_ptr<telegram_api::PhotoSize> &&size_ptr,
PhotoFormat format); PhotoFormat format, bool expect_jpeg_minithumbnail);
AnimationSize get_animation_size(FileManager *file_manager, PhotoSizeSource source, int64 id, int64 access_hash, AnimationSize get_animation_size(FileManager *file_manager, PhotoSizeSource source, int64 id, int64 access_hash,
string file_reference, DcId dc_id, DialogId owner_dialog_id, string file_reference, DcId dc_id, DialogId owner_dialog_id,
tl_object_ptr<telegram_api::videoSize> &&size); tl_object_ptr<telegram_api::videoSize> &&size);

View File

@ -1547,19 +1547,24 @@ FileId StickersManager::on_get_sticker(unique_ptr<Sticker> new_sticker, bool rep
} }
if (s->alt != new_sticker->alt && !new_sticker->alt.empty()) { if (s->alt != new_sticker->alt && !new_sticker->alt.empty()) {
LOG(DEBUG) << "Sticker " << file_id << " emoji has changed"; LOG(DEBUG) << "Sticker " << file_id << " emoji has changed";
s->alt = new_sticker->alt; s->alt = std::move(new_sticker->alt);
s->is_changed = true;
}
if (s->minithumbnail != new_sticker->minithumbnail) {
LOG(DEBUG) << "Sticker " << file_id << " minithumbnail has changed";
s->minithumbnail = std::move(new_sticker->minithumbnail);
s->is_changed = true; s->is_changed = true;
} }
if (s->s_thumbnail != new_sticker->s_thumbnail && new_sticker->s_thumbnail.file_id.is_valid()) { if (s->s_thumbnail != new_sticker->s_thumbnail && new_sticker->s_thumbnail.file_id.is_valid()) {
LOG_IF(INFO, s->s_thumbnail.file_id.is_valid()) << "Sticker " << file_id << " s thumbnail has changed from " LOG_IF(INFO, s->s_thumbnail.file_id.is_valid()) << "Sticker " << file_id << " s thumbnail has changed from "
<< s->s_thumbnail << " to " << new_sticker->s_thumbnail; << s->s_thumbnail << " to " << new_sticker->s_thumbnail;
s->s_thumbnail = new_sticker->s_thumbnail; s->s_thumbnail = std::move(new_sticker->s_thumbnail);
s->is_changed = true; s->is_changed = true;
} }
if (s->m_thumbnail != new_sticker->m_thumbnail && new_sticker->m_thumbnail.file_id.is_valid()) { if (s->m_thumbnail != new_sticker->m_thumbnail && new_sticker->m_thumbnail.file_id.is_valid()) {
LOG_IF(INFO, s->m_thumbnail.file_id.is_valid()) << "Sticker " << file_id << " m thumbnail has changed from " LOG_IF(INFO, s->m_thumbnail.file_id.is_valid()) << "Sticker " << file_id << " m thumbnail has changed from "
<< s->m_thumbnail << " to " << new_sticker->m_thumbnail; << s->m_thumbnail << " to " << new_sticker->m_thumbnail;
s->m_thumbnail = new_sticker->m_thumbnail; s->m_thumbnail = std::move(new_sticker->m_thumbnail);
s->is_changed = true; s->is_changed = true;
} }
if (s->is_animated != new_sticker->is_animated && new_sticker->is_animated) { if (s->is_animated != new_sticker->is_animated && new_sticker->is_animated) {
@ -1635,20 +1640,24 @@ std::pair<int64, FileId> StickersManager::on_get_sticker_document(
PSTRING() << document_id << (is_animated ? ".tgs" : ".webp")); PSTRING() << document_id << (is_animated ? ".tgs" : ".webp"));
PhotoSize thumbnail; PhotoSize thumbnail;
string minithumbnail;
for (auto &thumb : document->thumbs_) { for (auto &thumb : document->thumbs_) {
auto photo_size = auto photo_size =
get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, document_id, document->access_hash_, get_photo_size(td_->file_manager_.get(), {FileType::Thumbnail, 0}, document_id, document->access_hash_,
document->file_reference_.as_slice().str(), dc_id, DialogId(), std::move(thumb), document->file_reference_.as_slice().str(), dc_id, DialogId(), std::move(thumb),
has_webp_thumbnail(sticker) ? PhotoFormat::Webp : PhotoFormat::Jpeg); has_webp_thumbnail(sticker) ? PhotoFormat::Webp : PhotoFormat::Jpeg, false);
if (photo_size.get_offset() == 0) { if (photo_size.get_offset() == 0) {
thumbnail = std::move(photo_size.get<0>()); if (!thumbnail.file_id.is_valid()) {
thumbnail = std::move(photo_size.get<0>());
}
break; break;
} else { } else {
LOG(ERROR) << "Receive minithumbnail for a sticker " << sticker_id << ": " << to_string(sticker); minithumbnail = std::move(photo_size.get<1>());
} }
} }
create_sticker(sticker_id, std::move(thumbnail), dimensions, std::move(sticker), is_animated, nullptr); create_sticker(sticker_id, std::move(minithumbnail), std::move(thumbnail), dimensions, std::move(sticker),
is_animated, nullptr);
return {document_id, sticker_id}; return {document_id, sticker_id};
} }
@ -1963,7 +1972,7 @@ void StickersManager::add_sticker_thumbnail(Sticker *s, PhotoSize thumbnail) {
LOG(ERROR) << "Receive sticker thumbnail of unsupported type " << thumbnail.type; LOG(ERROR) << "Receive sticker thumbnail of unsupported type " << thumbnail.type;
} }
void StickersManager::create_sticker(FileId file_id, PhotoSize thumbnail, Dimensions dimensions, void StickersManager::create_sticker(FileId file_id, string minithumbnail, PhotoSize thumbnail, Dimensions dimensions,
tl_object_ptr<telegram_api::documentAttributeSticker> sticker, bool is_animated, tl_object_ptr<telegram_api::documentAttributeSticker> sticker, bool is_animated,
MultiPromiseActor *load_data_multipromise_ptr) { MultiPromiseActor *load_data_multipromise_ptr) {
if (is_animated && dimensions.width == 0) { if (is_animated && dimensions.width == 0) {
@ -1974,6 +1983,7 @@ void StickersManager::create_sticker(FileId file_id, PhotoSize thumbnail, Dimens
auto s = make_unique<Sticker>(); auto s = make_unique<Sticker>();
s->file_id = file_id; s->file_id = file_id;
s->dimensions = dimensions; s->dimensions = dimensions;
s->minithumbnail = std::move(minithumbnail);
add_sticker_thumbnail(s.get(), thumbnail); add_sticker_thumbnail(s.get(), thumbnail);
if (sticker != nullptr) { if (sticker != nullptr) {
s->set_id = on_get_input_sticker_set(file_id, std::move(sticker->stickerset_), load_data_multipromise_ptr); s->set_id = on_get_input_sticker_set(file_id, std::move(sticker->stickerset_), load_data_multipromise_ptr);
@ -2158,14 +2168,17 @@ StickerSetId StickersManager::on_get_sticker_set(tl_object_ptr<telegram_api::sti
bool is_masks = (set->flags_ & telegram_api::stickerSet::MASKS_MASK) != 0; bool is_masks = (set->flags_ & telegram_api::stickerSet::MASKS_MASK) != 0;
PhotoSize thumbnail; PhotoSize thumbnail;
string minithumbnail;
if (set->thumb_ != nullptr) { if (set->thumb_ != nullptr) {
auto photo_size = get_photo_size(td_->file_manager_.get(), {set_id.get(), s->access_hash}, 0, 0, "", auto photo_size = get_photo_size(td_->file_manager_.get(), {set_id.get(), s->access_hash}, 0, 0, "",
DcId::create(set->thumb_dc_id_), DialogId(), std::move(set->thumb_), DcId::create(set->thumb_dc_id_), DialogId(), std::move(set->thumb_),
is_animated ? PhotoFormat::Tgs : PhotoFormat::Webp); is_animated ? PhotoFormat::Tgs : PhotoFormat::Webp, false);
if (photo_size.get_offset() == 0) { if (photo_size.get_offset() == 0) {
thumbnail = std::move(photo_size.get<0>()); if (!thumbnail.file_id.is_valid()) {
thumbnail = std::move(photo_size.get<0>());
}
} else { } else {
LOG(ERROR) << "Receive minithumbnail for a " << set_id; minithumbnail = std::move(photo_size.get<1>());
} }
} }
if (!s->is_inited) { if (!s->is_inited) {
@ -2173,9 +2186,10 @@ StickerSetId StickersManager::on_get_sticker_set(tl_object_ptr<telegram_api::sti
s->is_inited = true; s->is_inited = true;
s->title = std::move(set->title_); s->title = std::move(set->title_);
s->short_name = std::move(set->short_name_); s->short_name = std::move(set->short_name_);
s->minithumbnail = std::move(minithumbnail);
s->thumbnail = std::move(thumbnail); s->thumbnail = std::move(thumbnail);
s->is_thumbnail_reloaded = true; s->is_thumbnail_reloaded = true;
s->are_legacy_thumbnails_reloaded = true; s->are_legacy_sticker_thumbnails_reloaded = true;
s->sticker_count = set->count_; s->sticker_count = set->count_;
s->hash = set->hash_; s->hash = set->hash_;
s->is_official = is_official; s->is_official = is_official;
@ -2209,15 +2223,20 @@ StickerSetId StickersManager::on_get_sticker_set(tl_object_ptr<telegram_api::sti
installed_sticker_sets_hints_[s->is_masks].add(set_id.get(), PSLICE() << s->title << ' ' << s->short_name); installed_sticker_sets_hints_[s->is_masks].add(set_id.get(), PSLICE() << s->title << ' ' << s->short_name);
} }
} }
if (s->minithumbnail != minithumbnail) {
LOG(INFO) << "Minithumbnail of " << set_id << " has changed";
s->minithumbnail = std::move(minithumbnail);
s->is_changed = true;
}
if (s->thumbnail != thumbnail) { if (s->thumbnail != thumbnail) {
LOG(INFO) << "Thumbnail of " << set_id << " has changed from " << s->thumbnail << " to " << thumbnail; LOG(INFO) << "Thumbnail of " << set_id << " has changed from " << s->thumbnail << " to " << thumbnail;
s->thumbnail = std::move(thumbnail); s->thumbnail = std::move(thumbnail);
s->is_changed = true; s->is_changed = true;
} }
if (!s->is_thumbnail_reloaded || !s->are_legacy_thumbnails_reloaded) { if (!s->is_thumbnail_reloaded || !s->are_legacy_sticker_thumbnails_reloaded) {
LOG(INFO) << "Sticker thumbnails and thumbnail of " << set_id << " was reloaded"; LOG(INFO) << "Sticker thumbnails and thumbnail of " << set_id << " was reloaded";
s->is_thumbnail_reloaded = true; s->is_thumbnail_reloaded = true;
s->are_legacy_thumbnails_reloaded = true; s->are_legacy_sticker_thumbnails_reloaded = true;
s->need_save_to_database = true; s->need_save_to_database = true;
} }
@ -3399,7 +3418,7 @@ void StickersManager::on_load_sticker_set_from_database(StickerSetId sticker_set
<< format::as_hex_dump<4>(Slice(value)); << format::as_hex_dump<4>(Slice(value));
} }
} }
if (!sticker_set->is_thumbnail_reloaded || !sticker_set->are_legacy_thumbnails_reloaded) { if (!sticker_set->is_thumbnail_reloaded || !sticker_set->are_legacy_sticker_thumbnails_reloaded) {
do_reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto()); do_reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto());
} }
@ -4290,7 +4309,7 @@ Result<std::tuple<FileId, bool, bool, bool>> StickersManager::prepare_input_file
if (is_animated) { if (is_animated) {
int32 width = for_thumbnail ? 100 : 512; int32 width = for_thumbnail ? 100 : 512;
create_sticker(file_id, PhotoSize(), get_dimensions(width, width), nullptr, true, nullptr); create_sticker(file_id, string(), PhotoSize(), get_dimensions(width, width), nullptr, true, nullptr);
} else { } else {
td_->documents_manager_->create_document(file_id, string(), PhotoSize(), "sticker.png", "image/png", false); td_->documents_manager_->create_document(file_id, string(), PhotoSize(), "sticker.png", "image/png", false);
} }

View File

@ -69,7 +69,7 @@ class StickersManager : public Actor {
void unregister_dice(const string &emoji, int32 value, FullMessageId full_message_id, const char *source); void unregister_dice(const string &emoji, int32 value, FullMessageId full_message_id, const char *source);
void create_sticker(FileId file_id, PhotoSize thumbnail, Dimensions dimensions, void create_sticker(FileId file_id, string minithumbnail, PhotoSize thumbnail, Dimensions dimensions,
tl_object_ptr<telegram_api::documentAttributeSticker> sticker, bool is_animated, tl_object_ptr<telegram_api::documentAttributeSticker> sticker, bool is_animated,
MultiPromiseActor *load_data_multipromise_ptr); MultiPromiseActor *load_data_multipromise_ptr);
@ -304,6 +304,7 @@ class StickersManager : public Actor {
StickerSetId set_id; StickerSetId set_id;
string alt; string alt;
Dimensions dimensions; Dimensions dimensions;
string minithumbnail;
PhotoSize s_thumbnail; PhotoSize s_thumbnail;
PhotoSize m_thumbnail; PhotoSize m_thumbnail;
FileId file_id; FileId file_id;
@ -331,6 +332,7 @@ class StickersManager : public Actor {
int32 hash = 0; int32 hash = 0;
int32 expires_at = 0; int32 expires_at = 0;
string minithumbnail;
PhotoSize thumbnail; PhotoSize thumbnail;
vector<FileId> sticker_ids; vector<FileId> sticker_ids;
@ -344,7 +346,7 @@ class StickersManager : public Actor {
bool is_masks = false; bool is_masks = false;
bool is_viewed = true; bool is_viewed = true;
bool is_thumbnail_reloaded = false; bool is_thumbnail_reloaded = false;
bool are_legacy_thumbnails_reloaded = false; bool are_legacy_sticker_thumbnails_reloaded = false;
mutable bool was_update_sent = false; // does the sticker set is known to the client mutable bool was_update_sent = false; // does the sticker set is known to the client
bool is_changed = true; // have new changes that need to be sent to the client and database bool is_changed = true; // have new changes that need to be sent to the client and database
bool need_save_to_database = true; // have new changes that need only to be saved to the database bool need_save_to_database = true; // have new changes that need only to be saved to the database

View File

@ -25,11 +25,13 @@ void StickersManager::store_sticker(FileId file_id, bool in_sticker_set, StorerT
CHECK(it != stickers_.end()); CHECK(it != stickers_.end());
const Sticker *sticker = it->second.get(); const Sticker *sticker = it->second.get();
bool has_sticker_set_access_hash = sticker->set_id.is_valid() && !in_sticker_set; bool has_sticker_set_access_hash = sticker->set_id.is_valid() && !in_sticker_set;
bool has_minithumbnail = !sticker->minithumbnail.empty();
BEGIN_STORE_FLAGS(); BEGIN_STORE_FLAGS();
STORE_FLAG(sticker->is_mask); STORE_FLAG(sticker->is_mask);
STORE_FLAG(has_sticker_set_access_hash); STORE_FLAG(has_sticker_set_access_hash);
STORE_FLAG(in_sticker_set); STORE_FLAG(in_sticker_set);
STORE_FLAG(sticker->is_animated); STORE_FLAG(sticker->is_animated);
STORE_FLAG(has_minithumbnail);
END_STORE_FLAGS(); END_STORE_FLAGS();
if (!in_sticker_set) { if (!in_sticker_set) {
store(sticker->set_id.get(), storer); store(sticker->set_id.get(), storer);
@ -50,6 +52,9 @@ void StickersManager::store_sticker(FileId file_id, bool in_sticker_set, StorerT
store(sticker->y_shift, storer); store(sticker->y_shift, storer);
store(sticker->scale, storer); store(sticker->scale, storer);
} }
if (has_minithumbnail) {
store(sticker->minithumbnail, storer);
}
} }
template <class ParserT> template <class ParserT>
@ -61,11 +66,13 @@ FileId StickersManager::parse_sticker(bool in_sticker_set, ParserT &parser) {
auto sticker = make_unique<Sticker>(); auto sticker = make_unique<Sticker>();
bool has_sticker_set_access_hash; bool has_sticker_set_access_hash;
bool in_sticker_set_stored; bool in_sticker_set_stored;
bool has_minithumbnail;
BEGIN_PARSE_FLAGS(); BEGIN_PARSE_FLAGS();
PARSE_FLAG(sticker->is_mask); PARSE_FLAG(sticker->is_mask);
PARSE_FLAG(has_sticker_set_access_hash); PARSE_FLAG(has_sticker_set_access_hash);
PARSE_FLAG(in_sticker_set_stored); PARSE_FLAG(in_sticker_set_stored);
PARSE_FLAG(sticker->is_animated); PARSE_FLAG(sticker->is_animated);
PARSE_FLAG(has_minithumbnail);
END_PARSE_FLAGS(); END_PARSE_FLAGS();
if (in_sticker_set_stored != in_sticker_set) { if (in_sticker_set_stored != in_sticker_set) {
Slice data = parser.template fetch_string_raw<Slice>(parser.get_left_len()); Slice data = parser.template fetch_string_raw<Slice>(parser.get_left_len());
@ -105,6 +112,9 @@ FileId StickersManager::parse_sticker(bool in_sticker_set, ParserT &parser) {
parse(sticker->y_shift, parser); parse(sticker->y_shift, parser);
parse(sticker->scale, parser); parse(sticker->scale, parser);
} }
if (has_minithumbnail) {
parse(sticker->minithumbnail, parser);
}
if (parser.get_error() != nullptr || !sticker->file_id.is_valid()) { if (parser.get_error() != nullptr || !sticker->file_id.is_valid()) {
return FileId(); return FileId();
} }
@ -119,6 +129,7 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with
bool is_loaded = sticker_set->is_loaded && is_full; bool is_loaded = sticker_set->is_loaded && is_full;
bool has_expires_at = !sticker_set->is_installed && sticker_set->expires_at != 0; bool has_expires_at = !sticker_set->is_installed && sticker_set->expires_at != 0;
bool has_thumbnail = sticker_set->thumbnail.file_id.is_valid(); bool has_thumbnail = sticker_set->thumbnail.file_id.is_valid();
bool has_minithumbnail = !sticker_set->minithumbnail.empty();
BEGIN_STORE_FLAGS(); BEGIN_STORE_FLAGS();
STORE_FLAG(sticker_set->is_inited); STORE_FLAG(sticker_set->is_inited);
STORE_FLAG(was_loaded); STORE_FLAG(was_loaded);
@ -132,7 +143,8 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with
STORE_FLAG(has_thumbnail); STORE_FLAG(has_thumbnail);
STORE_FLAG(sticker_set->is_thumbnail_reloaded); STORE_FLAG(sticker_set->is_thumbnail_reloaded);
STORE_FLAG(sticker_set->is_animated); STORE_FLAG(sticker_set->is_animated);
STORE_FLAG(sticker_set->are_legacy_thumbnails_reloaded); STORE_FLAG(sticker_set->are_legacy_sticker_thumbnails_reloaded);
STORE_FLAG(has_minithumbnail);
END_STORE_FLAGS(); END_STORE_FLAGS();
store(sticker_set->id.get(), storer); store(sticker_set->id.get(), storer);
store(sticker_set->access_hash, storer); store(sticker_set->access_hash, storer);
@ -147,6 +159,9 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with
if (has_thumbnail) { if (has_thumbnail) {
store(sticker_set->thumbnail, storer); store(sticker_set->thumbnail, storer);
} }
if (has_minithumbnail) {
store(sticker_set->minithumbnail, storer);
}
uint32 stored_sticker_count = narrow_cast<uint32>(is_full ? sticker_set->sticker_ids.size() : stickers_limit); uint32 stored_sticker_count = narrow_cast<uint32>(is_full ? sticker_set->sticker_ids.size() : stickers_limit);
store(stored_sticker_count, storer); store(stored_sticker_count, storer);
@ -175,9 +190,10 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser
bool is_archived; bool is_archived;
bool is_official; bool is_official;
bool is_masks; bool is_masks;
bool is_animated;
bool has_expires_at; bool has_expires_at;
bool has_thumbnail; bool has_thumbnail;
bool is_animated;
bool has_minithumbnail;
BEGIN_PARSE_FLAGS(); BEGIN_PARSE_FLAGS();
PARSE_FLAG(sticker_set->is_inited); PARSE_FLAG(sticker_set->is_inited);
PARSE_FLAG(sticker_set->was_loaded); PARSE_FLAG(sticker_set->was_loaded);
@ -191,7 +207,8 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser
PARSE_FLAG(has_thumbnail); PARSE_FLAG(has_thumbnail);
PARSE_FLAG(sticker_set->is_thumbnail_reloaded); PARSE_FLAG(sticker_set->is_thumbnail_reloaded);
PARSE_FLAG(is_animated); PARSE_FLAG(is_animated);
PARSE_FLAG(sticker_set->are_legacy_thumbnails_reloaded); PARSE_FLAG(sticker_set->are_legacy_sticker_thumbnails_reloaded);
PARSE_FLAG(has_minithumbnail);
END_PARSE_FLAGS(); END_PARSE_FLAGS();
int64 sticker_set_id; int64 sticker_set_id;
int64 access_hash; int64 access_hash;
@ -206,6 +223,8 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser
if (sticker_set->is_inited) { if (sticker_set->is_inited) {
string title; string title;
string short_name; string short_name;
string minithumbnail;
PhotoSize thumbnail;
int32 sticker_count; int32 sticker_count;
int32 hash; int32 hash;
int32 expires_at = 0; int32 expires_at = 0;
@ -217,11 +236,17 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser
parse(expires_at, parser); parse(expires_at, parser);
} }
if (has_thumbnail) { if (has_thumbnail) {
parse(sticker_set->thumbnail, parser); parse(thumbnail, parser);
} }
if (has_minithumbnail) {
parse(minithumbnail, parser);
}
if (!was_inited) { if (!was_inited) {
sticker_set->title = std::move(title); sticker_set->title = std::move(title);
sticker_set->short_name = std::move(short_name); sticker_set->short_name = std::move(short_name);
sticker_set->minithumbnail = std::move(minithumbnail);
sticker_set->thumbnail = std::move(thumbnail);
sticker_set->sticker_count = sticker_count; sticker_set->sticker_count = sticker_count;
sticker_set->hash = hash; sticker_set->hash = hash;
sticker_set->expires_at = expires_at; sticker_set->expires_at = expires_at;

View File

@ -8,7 +8,7 @@
namespace td { namespace td {
constexpr int32 MTPROTO_LAYER = 120; constexpr int32 MTPROTO_LAYER = 121;
enum class Version : int32 { enum class Version : int32 {
Initial, // 0 Initial, // 0