Support premium reactions.

This commit is contained in:
levlam 2022-04-26 14:40:06 +03:00
parent 61409736ad
commit f8077965ad
4 changed files with 12 additions and 6 deletions

View File

@ -2487,6 +2487,7 @@ availableReactions reactions:vector<string> = AvailableReactions;
//@reaction Text representation of the reaction
//@title Reaction title
//@is_active True, if the reaction can be added to new messages and enabled in chats
//@is_premium True, if the reaction is available only for premium users
//@static_icon Static icon for the reaction
//@appear_animation Appear animation for the reaction
//@select_animation Select animation for the reaction
@ -2494,7 +2495,7 @@ availableReactions reactions:vector<string> = AvailableReactions;
//@effect_animation Effect animation for the reaction
//@around_animation Around animation for the reaction; may be null
//@center_animation Center animation for the reaction; may be null
reaction reaction:string title:string is_active:Bool static_icon:sticker appear_animation:sticker select_animation:sticker activate_animation:sticker effect_animation:sticker around_animation:sticker center_animation:sticker = Reaction;
reaction reaction:string title:string is_active:Bool is_premium:Bool static_icon:sticker appear_animation:sticker select_animation:sticker activate_animation:sticker effect_animation:sticker around_animation:sticker center_animation:sticker = Reaction;
//@description Represents a list of animations @animations List of animations
@ -4848,7 +4849,7 @@ editInlineMessageReplyMarkup inline_message_id:string reply_markup:ReplyMarkup =
editMessageSchedulingState chat_id:int53 message_id:int53 scheduling_state:MessageSchedulingState = Ok;
//@description Returns reactions, which can be added to a message. The list can change after updateReactions, updateChatAvailableReactions for the chat, or updateMessageInteractionInfo for the message
//@description Returns reactions, which can be added to a message. The list can change after updateReactions, updateChatAvailableReactions for the chat, or updateMessageInteractionInfo for the message. The method will return Premium reactions, even the current user has no Premium account
//@chat_id Identifier of the chat to which the message belongs
//@message_id Identifier of the message
getMessageAvailableReactions chat_id:int53 message_id:int53 = AvailableReactions;

View File

@ -3210,10 +3210,11 @@ void StickersManager::on_get_special_sticker_set(const SpecialStickerSetType &ty
td_api::object_ptr<td_api::updateReactions> StickersManager::get_update_reactions_object() const {
auto reactions = transform(reactions_.reactions_, [this](const Reaction &reaction) {
return td_api::make_object<td_api::reaction>(
reaction.reaction_, reaction.title_, reaction.is_active_, get_sticker_object(reaction.static_icon_),
get_sticker_object(reaction.appear_animation_), get_sticker_object(reaction.select_animation_),
get_sticker_object(reaction.activate_animation_), get_sticker_object(reaction.effect_animation_),
get_sticker_object(reaction.around_animation_), get_sticker_object(reaction.center_animation_));
reaction.reaction_, reaction.title_, reaction.is_active_, reaction.is_premium_,
get_sticker_object(reaction.static_icon_), get_sticker_object(reaction.appear_animation_),
get_sticker_object(reaction.select_animation_), get_sticker_object(reaction.activate_animation_),
get_sticker_object(reaction.effect_animation_), get_sticker_object(reaction.around_animation_),
get_sticker_object(reaction.center_animation_));
});
return td_api::make_object<td_api::updateReactions>(std::move(reactions));
}
@ -3282,6 +3283,7 @@ void StickersManager::on_get_available_reactions(
for (auto &available_reaction : available_reactions->reactions_) {
Reaction reaction;
reaction.is_active_ = !available_reaction->inactive_;
reaction.is_premium_ = available_reaction->premium_;
reaction.reaction_ = std::move(available_reaction->reaction_);
reaction.title_ = std::move(available_reaction->title_);
reaction.static_icon_ =

View File

@ -448,6 +448,7 @@ class StickersManager final : public Actor {
string reaction_;
string title_;
bool is_active_ = false;
bool is_premium_ = false;
FileId static_icon_;
FileId appear_animation_;
FileId select_animation_;

View File

@ -396,6 +396,7 @@ void StickersManager::Reaction::store(StorerT &storer) const {
STORE_FLAG(is_active_);
STORE_FLAG(has_around_animation);
STORE_FLAG(has_center_animation);
STORE_FLAG(is_premium_);
END_STORE_FLAGS();
td::store(reaction_, storer);
td::store(title_, storer);
@ -421,6 +422,7 @@ void StickersManager::Reaction::parse(ParserT &parser) {
PARSE_FLAG(is_active_);
PARSE_FLAG(has_around_animation);
PARSE_FLAG(has_center_animation);
PARSE_FLAG(is_premium_);
END_PARSE_FLAGS();
td::parse(reaction_, parser);
td::parse(title_, parser);