Treat all emoji reactions as non-premium.
This commit is contained in:
parent
663389f19d
commit
4e6046b9ec
@ -2563,18 +2563,14 @@ addedReaction type:ReactionType sender_id:MessageSender = AddedReaction;
|
||||
//@description Represents a list of reactions added to a message @total_count The total number of found reactions @reactions The list of added reactions @next_offset The offset for the next request. If empty, there are no more results
|
||||
addedReactions total_count:int32 reactions:vector<addedReaction> next_offset:string = AddedReactions;
|
||||
|
||||
//@description Represents an available reaction @reaction Text representation of the reaction @needs_premium True, if Telegram Premium is needed to send the reaction
|
||||
availableReaction reaction:string needs_premium:Bool = AvailableReaction;
|
||||
|
||||
//@description Represents a list of available reactions @reactions List of reactions
|
||||
availableReactions reactions:vector<availableReaction> = AvailableReactions;
|
||||
//@description Represents a list of available reactions @reactions List of available reactions
|
||||
availableReactions reactions:vector<ReactionType> = AvailableReactions;
|
||||
|
||||
|
||||
//@description Contains stickers which must be used for emoji reaction animation rendering
|
||||
//@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
|
||||
@ -2582,7 +2578,7 @@ availableReactions reactions:vector<availableReaction> = 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 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;
|
||||
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;
|
||||
|
||||
|
||||
//@description Represents a list of animations @animations List of animations
|
||||
|
@ -11,11 +11,11 @@
|
||||
namespace td {
|
||||
|
||||
AvailableReactionType get_reaction_type(const vector<AvailableReaction> &available_reactions, const string &reaction) {
|
||||
if (reaction[0] == '#') {
|
||||
return AvailableReactionType::NeedsPremium;
|
||||
}
|
||||
for (auto &available_reaction : available_reactions) {
|
||||
if (available_reaction.reaction_ == reaction) {
|
||||
if (available_reaction.is_premium_) {
|
||||
return AvailableReactionType::NeedsPremium;
|
||||
}
|
||||
return AvailableReactionType::Available;
|
||||
}
|
||||
}
|
||||
@ -50,12 +50,8 @@ vector<string> get_active_reactions(const vector<string> &available_reactions,
|
||||
return result;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::availableReaction> AvailableReaction::get_available_reaction_object() const {
|
||||
return td_api::make_object<td_api::availableReaction>(reaction_, is_premium_);
|
||||
}
|
||||
|
||||
bool operator==(const AvailableReaction &lhs, const AvailableReaction &rhs) {
|
||||
return lhs.reaction_ == rhs.reaction_ && lhs.is_premium_ == rhs.is_premium_;
|
||||
return lhs.reaction_ == rhs.reaction_;
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -14,12 +14,9 @@ namespace td {
|
||||
|
||||
struct AvailableReaction {
|
||||
string reaction_;
|
||||
bool is_premium_;
|
||||
|
||||
AvailableReaction(const string &reaction, bool is_premium) : reaction_(reaction), is_premium_(is_premium) {
|
||||
explicit AvailableReaction(const string &reaction) : reaction_(reaction) {
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::availableReaction> get_available_reaction_object() const;
|
||||
};
|
||||
|
||||
bool operator==(const AvailableReaction &lhs, const AvailableReaction &rhs);
|
||||
|
@ -47,7 +47,7 @@ static string get_custom_emoji_string(int64 custom_emoji_id) {
|
||||
return PSTRING() << '#' << base64_encode(Slice(s, 8));
|
||||
}
|
||||
|
||||
static telegram_api::object_ptr<telegram_api::Reaction> get_input_reaction(const string &reaction) {
|
||||
telegram_api::object_ptr<telegram_api::Reaction> get_input_reaction(const string &reaction) {
|
||||
if (reaction.empty()) {
|
||||
return telegram_api::make_object<telegram_api::reactionEmpty>();
|
||||
}
|
||||
@ -80,7 +80,7 @@ string get_message_reaction_string(const telegram_api::object_ptr<telegram_api::
|
||||
}
|
||||
}
|
||||
|
||||
static td_api::object_ptr<td_api::ReactionType> get_reaction_type_object(const string &reaction) {
|
||||
td_api::object_ptr<td_api::ReactionType> get_reaction_type_object(const string &reaction) {
|
||||
CHECK(!reaction.empty());
|
||||
if (reaction[0] == '#') {
|
||||
return td_api::make_object<td_api::reactionTypeCustomEmoji>(get_custom_emoji_id(reaction));
|
||||
|
@ -173,6 +173,10 @@ StringBuilder &operator<<(StringBuilder &string_builder, const MessageReactions
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const unique_ptr<MessageReactions> &reactions);
|
||||
|
||||
telegram_api::object_ptr<telegram_api::Reaction> get_input_reaction(const string &reaction);
|
||||
|
||||
td_api::object_ptr<td_api::ReactionType> get_reaction_type_object(const string &reaction);
|
||||
|
||||
string get_message_reaction_string(const telegram_api::object_ptr<telegram_api::Reaction> &reaction);
|
||||
|
||||
string get_message_reaction_string(const td_api::object_ptr<td_api::ReactionType> &type);
|
||||
|
@ -24399,7 +24399,7 @@ vector<AvailableReaction> MessagesManager::get_message_available_reactions(const
|
||||
// can add the reaction if it has already been used for the message or is available in the chat
|
||||
bool is_set = (m->reactions != nullptr && m->reactions->get_reaction(active_reaction.reaction_) != nullptr);
|
||||
if (is_set || (can_add_new_reactions && td::contains(active_reactions, active_reaction.reaction_))) {
|
||||
result.emplace_back(active_reaction.reaction_, !is_premium && active_reaction.is_premium_ && !is_set);
|
||||
result.emplace_back(active_reaction.reaction_);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -24409,7 +24409,7 @@ vector<AvailableReaction> MessagesManager::get_message_available_reactions(const
|
||||
get_reaction_type(result, reaction.get_reaction()) == AvailableReactionType::Unavailable) {
|
||||
CHECK(!can_use_reactions ||
|
||||
get_reaction_type(active_reactions_, reaction.get_reaction()) == AvailableReactionType::Unavailable);
|
||||
result.emplace_back(reaction.get_reaction(), false);
|
||||
result.emplace_back(reaction.get_reaction());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3640,11 +3640,10 @@ 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_, 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_));
|
||||
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_));
|
||||
});
|
||||
return td_api::make_object<td_api::updateReactions>(std::move(reactions));
|
||||
}
|
||||
@ -3685,7 +3684,7 @@ void StickersManager::update_active_reactions() {
|
||||
vector<AvailableReaction> active_reactions;
|
||||
for (auto &reaction : reactions_.reactions_) {
|
||||
if (reaction.is_active_) {
|
||||
active_reactions.emplace_back(reaction.reaction_, reaction.is_premium_);
|
||||
active_reactions.emplace_back(reaction.reaction_);
|
||||
}
|
||||
}
|
||||
td_->messages_manager_->set_active_reactions(std::move(active_reactions));
|
||||
@ -3735,6 +3734,10 @@ void StickersManager::on_get_available_reactions(
|
||||
LOG(ERROR) << "Receive invalid reaction " << reaction.reaction_;
|
||||
continue;
|
||||
}
|
||||
if (reaction.is_premium_) {
|
||||
LOG(ERROR) << "Receive premium reaction " << reaction.reaction_;
|
||||
continue;
|
||||
}
|
||||
|
||||
new_reactions.push_back(std::move(reaction));
|
||||
}
|
||||
|
@ -499,6 +499,8 @@ void StickersManager::Reaction::parse(ParserT &parser) {
|
||||
if (has_center_animation) {
|
||||
center_animation_ = stickers_manager->parse_sticker(false, parser);
|
||||
}
|
||||
|
||||
is_premium_ = false;
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
|
@ -5242,7 +5242,7 @@ void Td::on_request(uint64 id, const td_api::getMessageAvailableReactions &reque
|
||||
send_closure(actor_id(this), &Td::send_error, id, r_reactions.move_as_error());
|
||||
} else {
|
||||
auto reactions =
|
||||
transform(r_reactions.ok(), [](auto &reaction) { return reaction.get_available_reaction_object(); });
|
||||
transform(r_reactions.ok(), [](auto &reaction) { return get_reaction_type_object(reaction.reaction_); });
|
||||
send_closure(actor_id(this), &Td::send_result, id,
|
||||
td_api::make_object<td_api::availableReactions>(std::move(reactions)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user