Add explicit flag sticker.is_premium.

This commit is contained in:
levlam 2022-07-15 13:37:46 +03:00
parent ea8f81187e
commit 3bfb3cdbb1
5 changed files with 15 additions and 5 deletions

View File

@ -306,8 +306,8 @@ photo has_stickers:Bool minithumbnail:minithumbnail sizes:vector<photoSize> = Ph
//@description Describes a sticker @set_id The identifier of the sticker set to which the sticker belongs; 0 if none @width Sticker width; as defined by the sender @height Sticker height; as defined by the sender
//@emoji Emoji corresponding to the sticker @format Sticker format @type Sticker type @mask_position Position where the mask is placed; may be null even sticker is a mask
//@outline Sticker's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner
//@thumbnail Sticker thumbnail in WEBP or JPEG format; may be null @premium_animation Premium animation of the sticker; may be null. If present, only Premium users can send the sticker @sticker File containing the sticker
sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat type:StickerType mask_position:maskPosition outline:vector<closedVectorPath> thumbnail:thumbnail premium_animation:file sticker:file = Sticker;
//@thumbnail Sticker thumbnail in WEBP or JPEG format; may be null @is_premium True, if only Premium users can use the sticker @premium_animation Premium animation of the sticker; may be null @sticker File containing the sticker
sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat type:StickerType mask_position:maskPosition outline:vector<closedVectorPath> thumbnail:thumbnail is_premium:Bool premium_animation:file sticker:file = Sticker;
//@description Describes a video file @duration Duration of the video, in seconds; as defined by the sender @width Video width; as defined by the sender @height Video height; as defined by the sender
//@file_name Original name of the file; as defined by the sender @mime_type MIME type of the file; as defined by the sender

View File

@ -1246,7 +1246,7 @@ tl_object_ptr<td_api::sticker> copy(const td_api::sticker &obj) {
return td_api::make_object<td_api::sticker>(obj.set_id_, obj.width_, obj.height_, obj.emoji_, copy(obj.format_),
copy(obj.type_), copy(obj.mask_position_),
transform(obj.outline_, copy_closed_vector_path), copy(obj.thumbnail_),
copy(obj.premium_animation_), copy(obj.sticker_));
obj.is_premium_, copy(obj.premium_animation_), copy(obj.sticker_));
}
template <>

View File

@ -1915,7 +1915,8 @@ tl_object_ptr<td_api::sticker> StickersManager::get_sticker_object(FileId file_i
sticker->set_id.get(), width, height, sticker->alt, get_sticker_format_object(sticker->format),
get_sticker_type_object(sticker->type), std::move(mask_position),
get_sticker_minithumbnail(sticker->minithumbnail, sticker->set_id, document_id, zoom),
std::move(thumbnail_object), std::move(premium_animation_object), td_->file_manager_->get_file_object(file_id));
std::move(thumbnail_object), sticker->is_premium, std::move(premium_animation_object),
td_->file_manager_->get_file_object(file_id));
}
tl_object_ptr<td_api::stickers> StickersManager::get_stickers_object(const vector<FileId> &sticker_ids) const {
@ -2265,6 +2266,7 @@ FileId StickersManager::on_get_sticker(unique_ptr<Sticker> new_sticker, bool rep
<< s->m_thumbnail << " to " << new_sticker->m_thumbnail;
s->m_thumbnail = std::move(new_sticker->m_thumbnail);
}
s->is_premium = new_sticker->is_premium;
s->premium_animation_file_id = new_sticker->premium_animation_file_id;
if (s->format != new_sticker->format && new_sticker->format != StickerFormat::Unknown) {
s->format = new_sticker->format;
@ -2746,6 +2748,9 @@ void StickersManager::create_sticker(FileId file_id, FileId premium_animation_fi
s->minithumbnail = std::move(minithumbnail);
}
add_sticker_thumbnail(s.get(), std::move(thumbnail));
if (premium_animation_file_id.is_valid()) {
s->is_premium = true;
}
s->premium_animation_file_id = premium_animation_file_id;
if (sticker != nullptr) {
s->set_id = on_get_input_sticker_set(file_id, std::move(sticker->stickerset_), load_data_multipromise_ptr);
@ -2768,6 +2773,7 @@ void StickersManager::create_sticker(FileId file_id, FileId premium_animation_fi
s->set_id = on_get_input_sticker_set(file_id, std::move(custom_emoji->stickerset_), load_data_multipromise_ptr);
s->alt = std::move(custom_emoji->alt_);
s->type = StickerType::Emoji;
s->is_premium = !custom_emoji->free_;
}
s->format = format;
on_get_sticker(std::move(s),
@ -3527,7 +3533,7 @@ std::pair<vector<FileId>, vector<FileId>> StickersManager::split_stickers_by_pre
if (sticker_id.is_valid()) {
const Sticker *s = get_sticker(sticker_id);
CHECK(s != nullptr);
if (s->premium_animation_file_id.is_valid()) {
if (s->is_premium) {
premium_sticker_ids.push_back(sticker_id);
} else {
regular_sticker_ids.push_back(sticker_id);

View File

@ -367,6 +367,7 @@ class StickersManager final : public Actor {
FileId file_id;
StickerFormat format = StickerFormat::Unknown;
StickerType type = StickerType::Regular;
bool is_premium = false;
int32 point = -1;
double x_shift = 0;
double y_shift = 0;

View File

@ -45,6 +45,7 @@ void StickersManager::store_sticker(FileId file_id, bool in_sticker_set, StorerT
STORE_FLAG(is_webm);
STORE_FLAG(has_premium_animation);
STORE_FLAG(is_emoji);
STORE_FLAG(sticker->is_premium);
END_STORE_FLAGS();
if (!in_sticker_set) {
store(sticker->set_id.get(), storer);
@ -97,6 +98,7 @@ FileId StickersManager::parse_sticker(bool in_sticker_set, ParserT &parser) {
PARSE_FLAG(is_webm);
PARSE_FLAG(has_premium_animation);
PARSE_FLAG(is_emoji);
PARSE_FLAG(sticker->is_premium);
END_PARSE_FLAGS();
if (is_webm) {
sticker->format = StickerFormat::Webm;
@ -154,6 +156,7 @@ FileId StickersManager::parse_sticker(bool in_sticker_set, ParserT &parser) {
parse(sticker->minithumbnail, parser);
}
if (has_premium_animation) {
sticker->is_premium = true;
parse(sticker->premium_animation_file_id, parser);
}
if (parser.get_error() != nullptr || !sticker->file_id.is_valid()) {