From f8077965ad20a0177fa5ee4078650225a43aa177 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 26 Apr 2022 14:40:06 +0300 Subject: [PATCH] Support premium reactions. --- td/generate/scheme/td_api.tl | 5 +++-- td/telegram/StickersManager.cpp | 10 ++++++---- td/telegram/StickersManager.h | 1 + td/telegram/StickersManager.hpp | 2 ++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index a46e27d34..9a538e6c1 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2487,6 +2487,7 @@ availableReactions reactions:vector = 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 = 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; diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 6d2dd91cd..99b45ae8f 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -3210,10 +3210,11 @@ void StickersManager::on_get_special_sticker_set(const SpecialStickerSetType &ty td_api::object_ptr StickersManager::get_update_reactions_object() const { auto reactions = transform(reactions_.reactions_, [this](const Reaction &reaction) { return td_api::make_object( - 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(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_ = diff --git a/td/telegram/StickersManager.h b/td/telegram/StickersManager.h index cb0a12fb1..003be58a9 100644 --- a/td/telegram/StickersManager.h +++ b/td/telegram/StickersManager.h @@ -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_; diff --git a/td/telegram/StickersManager.hpp b/td/telegram/StickersManager.hpp index 7cc3cb7e7..e0c08e9ea 100644 --- a/td/telegram/StickersManager.hpp +++ b/td/telegram/StickersManager.hpp @@ -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);