Support sticker set thumbnails.
GitOrigin-RevId: 7eed134519d7bf5708691f13a2b1cc79579317ba
This commit is contained in:
parent
05840e3816
commit
c72f7e4eee
@ -1554,15 +1554,19 @@ stickers stickers:vector<sticker> = Stickers;
|
||||
//@description Represents a list of all emoji corresponding to a sticker in a sticker set. The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the corresponding Sticker object @emojis List of emojis
|
||||
stickerEmojis emojis:vector<string> = StickerEmojis;
|
||||
|
||||
//@description Represents a sticker set @id Identifier of the sticker set @title Title of the sticker set @name Name of the sticker set @is_installed True, if the sticker set has been installed by the current user
|
||||
//@is_archived True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously @is_official True, if the sticker set is official @is_masks True, if the stickers in the set are masks
|
||||
//@is_viewed True for already viewed trending sticker sets @stickers List of stickers in this set @emojis A list of emoji corresponding to the stickers in the same order
|
||||
stickerSet id:int64 title:string name:string is_installed:Bool is_archived:Bool is_official:Bool is_masks:Bool is_viewed:Bool stickers:vector<sticker> emojis:vector<stickerEmojis> = StickerSet;
|
||||
//@description Represents a sticker set
|
||||
//@id Identifier of the sticker set @title Title of the sticker set @name Name of the sticker set @thumbnail Sticker set thumbnail in WEBP format; may be null
|
||||
//@is_installed True, if the sticker set has been installed by the current user @is_archived True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously
|
||||
//@is_official True, if the sticker set is official @is_masks True, if the stickers in the set are masks @is_viewed True for already viewed trending sticker sets
|
||||
//@stickers List of stickers in this set @emojis A list of emoji corresponding to the stickers in the same order
|
||||
stickerSet id:int64 title:string name:string thumbnail:photoSize is_installed:Bool is_archived:Bool is_official:Bool is_masks:Bool is_viewed:Bool stickers:vector<sticker> emojis:vector<stickerEmojis> = StickerSet;
|
||||
|
||||
//@description Represents short information about a sticker set @id Identifier of the sticker set @title Title of the sticker set @name Name of the sticker set @is_installed True, if the sticker set has been installed by current user
|
||||
//@is_archived True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously @is_official True, if the sticker set is official @is_masks True, if the stickers in the set are masks
|
||||
//@is_viewed True for already viewed trending sticker sets @size Total number of stickers in the set @covers Contains up to the first 5 stickers from the set, depending on the context. If the client needs more stickers the full set should be requested
|
||||
stickerSetInfo id:int64 title:string name:string is_installed:Bool is_archived:Bool is_official:Bool is_masks:Bool is_viewed:Bool size:int32 covers:vector<sticker> = StickerSetInfo;
|
||||
//@description Represents short information about a sticker set
|
||||
//@id Identifier of the sticker set @title Title of the sticker set @name Name of the sticker set @thumbnail Sticker set thumbnail in WEBP format; may be null
|
||||
//@is_installed True, if the sticker set has been installed by current user @is_archived True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously
|
||||
//@is_official True, if the sticker set is official @is_masks True, if the stickers in the set are masks @is_viewed True for already viewed trending sticker sets
|
||||
//@size Total number of stickers in the set @covers Contains up to the first 5 stickers from the set, depending on the context. If the client needs more stickers the full set should be requested
|
||||
stickerSetInfo id:int64 title:string name:string thumbnail:photoSize is_installed:Bool is_archived:Bool is_official:Bool is_masks:Bool is_viewed:Bool size:int32 covers:vector<sticker> = StickerSetInfo;
|
||||
|
||||
//@description Represents a list of sticker sets @total_count Approximate total number of sticker sets found @sets List of sticker sets
|
||||
stickerSets total_count:int32 sets:vector<stickerSetInfo> = StickerSets;
|
||||
|
Binary file not shown.
@ -1005,6 +1005,7 @@ tl_object_ptr<td_api::stickerSet> StickersManager::get_sticker_set_object(int64
|
||||
}
|
||||
}
|
||||
return make_tl_object<td_api::stickerSet>(sticker_set->id, sticker_set->title, sticker_set->short_name,
|
||||
get_photo_size_object(td_->file_manager_.get(), &sticker_set->thumbnail),
|
||||
sticker_set->is_installed && !sticker_set->is_archived,
|
||||
sticker_set->is_archived, sticker_set->is_official, sticker_set->is_masks,
|
||||
sticker_set->is_viewed, std::move(stickers), std::move(emojis));
|
||||
@ -1048,6 +1049,7 @@ tl_object_ptr<td_api::stickerSetInfo> StickersManager::get_sticker_set_info_obje
|
||||
|
||||
return make_tl_object<td_api::stickerSetInfo>(
|
||||
sticker_set->id, sticker_set->title, sticker_set->short_name,
|
||||
get_photo_size_object(td_->file_manager_.get(), &sticker_set->thumbnail),
|
||||
sticker_set->is_installed && !sticker_set->is_archived, sticker_set->is_archived, sticker_set->is_official,
|
||||
sticker_set->is_masks, sticker_set->is_viewed,
|
||||
sticker_set->was_loaded ? narrow_cast<int32>(sticker_set->sticker_ids.size()) : sticker_set->sticker_count,
|
||||
@ -1620,10 +1622,19 @@ int64 StickersManager::on_get_sticker_set(tl_object_ptr<telegram_api::stickerSet
|
||||
bool is_official = (set->flags_ & 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 (!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->sticker_count = set->count_;
|
||||
s->hash = set->hash_;
|
||||
s->is_official = is_official;
|
||||
@ -1656,6 +1667,11 @@ int64 StickersManager::on_get_sticker_set(tl_object_ptr<telegram_api::stickerSet
|
||||
installed_sticker_sets_hints_[s->is_masks].add(set_id, PSLICE() << s->title << ' ' << s->short_name);
|
||||
}
|
||||
}
|
||||
if (s->thumbnail != thumbnail) {
|
||||
LOG(INFO) << "Sticker set " << set_id << " thumbnail has changed from " << s->thumbnail << " to " << thumbnail;
|
||||
s->thumbnail = std::move(thumbnail);
|
||||
s->is_changed = true;
|
||||
}
|
||||
|
||||
if (s->sticker_count != set->count_ || s->hash != set->hash_) {
|
||||
s->is_loaded = false;
|
||||
|
@ -276,6 +276,8 @@ class StickersManager : public Actor {
|
||||
int32 hash = 0;
|
||||
int32 expires_at = 0;
|
||||
|
||||
PhotoSize thumbnail;
|
||||
|
||||
vector<FileId> sticker_ids;
|
||||
std::unordered_map<string, vector<FileId>> emoji_stickers_map_; // emoji -> stickers
|
||||
std::unordered_map<FileId, vector<string>, FileIdHash> sticker_emojis_map_; // sticker -> emojis
|
||||
|
@ -110,6 +110,7 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with
|
||||
bool was_loaded = sticker_set->was_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_thumbnail = sticker_set->thumbnail.file_id.is_valid();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(sticker_set->is_inited);
|
||||
STORE_FLAG(was_loaded);
|
||||
@ -120,6 +121,7 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with
|
||||
STORE_FLAG(sticker_set->is_masks);
|
||||
STORE_FLAG(sticker_set->is_viewed);
|
||||
STORE_FLAG(has_expires_at);
|
||||
STORE_FLAG(has_thumbnail);
|
||||
END_STORE_FLAGS();
|
||||
store(sticker_set->id, storer);
|
||||
store(sticker_set->access_hash, storer);
|
||||
@ -131,6 +133,9 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with
|
||||
if (has_expires_at) {
|
||||
store(sticker_set->expires_at, storer);
|
||||
}
|
||||
if (has_thumbnail) {
|
||||
store(sticker_set->thumbnail, storer);
|
||||
}
|
||||
|
||||
uint32 stored_sticker_count = narrow_cast<uint32>(is_full ? sticker_set->sticker_ids.size() : stickers_limit);
|
||||
store(stored_sticker_count, storer);
|
||||
@ -160,6 +165,7 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser
|
||||
bool is_official;
|
||||
bool is_masks;
|
||||
bool has_expires_at;
|
||||
bool has_thumbnail;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(sticker_set->is_inited);
|
||||
PARSE_FLAG(sticker_set->was_loaded);
|
||||
@ -170,6 +176,7 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser
|
||||
PARSE_FLAG(is_masks);
|
||||
PARSE_FLAG(sticker_set->is_viewed);
|
||||
PARSE_FLAG(has_expires_at);
|
||||
PARSE_FLAG(has_thumbnail);
|
||||
END_PARSE_FLAGS();
|
||||
int64 sticker_set_id;
|
||||
int64 access_hash;
|
||||
@ -194,6 +201,9 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser
|
||||
if (has_expires_at) {
|
||||
parse(expires_at, parser);
|
||||
}
|
||||
if (has_thumbnail) {
|
||||
parse(sticker_set->thumbnail, parser);
|
||||
}
|
||||
if (!was_inited) {
|
||||
sticker_set->title = std::move(title);
|
||||
sticker_set->short_name = std::move(short_name);
|
||||
|
Reference in New Issue
Block a user