Add td_api::MessageEffectType.

This commit is contained in:
levlam 2024-05-08 10:59:30 +03:00
parent 7b7d60a394
commit 4b3e0ee8eb
3 changed files with 39 additions and 6 deletions

View File

@ -1392,14 +1392,24 @@ messageInteractionInfo view_count:int32 forward_count:int32 reply_info:messageRe
unreadReaction type:ReactionType sender_id:MessageSender is_big:Bool = UnreadReaction;
//@class MessageEffectType @description Describes type of an emoji effect
//@description An effect from an emoji reaction @select_animation Select animation for the effect in TGS format @effect_animation Effect animation for the effect in TGS format
messageEffectTypeEmojiReaction select_animation:sticker effect_animation:sticker = MessageEffectType;
//@description An effect from a premium sticker @sticker The premium sticker. The effect can be found at sticker.full_type.premium_animation
messageEffectTypePremiumSticker sticker:sticker = MessageEffectType;
//@description Contains information about an effect added to a message
//@id Unique identifier of the effect
//@static_icon Static icon for the effect in WEBP format; may be null if none
//@emoji Emoji corresponding to the effect that can be used if static icon isn't available
//@is_premium True, if Telegram Premium subscription is required to use the effect
messageEffect id:int64 static_icon:sticker emoji:string is_premium:Bool = MessageEffect;
//@type Type of the effect
messageEffect id:int64 static_icon:sticker emoji:string is_premium:Bool type:MessageEffectType = MessageEffect;
//@description Contains a list of message effects @effects List of available message effects
//@description Contains a list of message effects @effects List of available message effects. Emoji reaction effects are guaranteed to be returned before sticker effects
messageEffects effects:vector<messageEffect> = MessageEffects;
@ -3718,7 +3728,7 @@ trendingStickerSets total_count:int32 sets:vector<stickerSetInfo> is_premium:Boo
//@emojis List of emojis for search for
emojiCategorySourceSearch emojis:vector<string> = EmojiCategorySource;
//@description The category contains Premium stickers that must be found by getPremiumStickers
//@description The category contains premium stickers that must be found by getPremiumStickers
emojiCategorySourcePremium = EmojiCategorySource;
@ -3738,7 +3748,7 @@ emojiCategories categories:vector<emojiCategory> = EmojiCategories;
//@description The category must be used by default (e.g., for custom emoji or animation search)
emojiCategoryTypeDefault = EmojiCategoryType;
//@description The category must be used by default for regular sticker selection. It may contain greeting emoji category and Premium stickers
//@description The category must be used by default for regular sticker selection. It may contain greeting emoji category and premium stickers
emojiCategoryTypeRegularStickers = EmojiCategoryType;
//@description The category must be used for emoji status selection

View File

@ -1199,9 +1199,18 @@ void ReactionManager::set_saved_messages_tag_title(ReactionType reaction_type, s
}
td_api::object_ptr<td_api::messageEffect> ReactionManager::get_message_effect_object(const Effect &effect) const {
auto type = [&]() -> td_api::object_ptr<td_api::MessageEffectType> {
if (effect.is_sticker()) {
return td_api::make_object<td_api::messageEffectTypePremiumSticker>(
td_->stickers_manager_->get_sticker_object(effect.effect_sticker_id_));
}
return td_api::make_object<td_api::messageEffectTypeEmojiReaction>(
td_->stickers_manager_->get_sticker_object(effect.effect_sticker_id_),
td_->stickers_manager_->get_sticker_object(effect.effect_animation_id_));
}();
return td_api::make_object<td_api::messageEffect>(effect.id_,
td_->stickers_manager_->get_sticker_object(effect.static_icon_id_),
effect.emoji_, effect.is_premium_);
effect.emoji_, effect.is_premium_, std::move(type));
}
td_api::object_ptr<td_api::messageEffects> ReactionManager::get_message_effects_object() const {
@ -1243,6 +1252,8 @@ void ReactionManager::on_get_message_effects(
}
}
vector<Effect> new_effects;
bool was_sticker = false;
bool have_invalid_order = false;
for (const auto &available_effect : effects->effects_) {
Effect effect;
effect.id_ = available_effect->id_;
@ -1288,11 +1299,19 @@ void ReactionManager::on_get_message_effects(
}
}
if (effect.is_valid()) {
if (was_sticker && !effect.is_sticker()) {
have_invalid_order = true;
}
new_effects.push_back(std::move(effect));
} else {
// LOG(ERROR) << "Receive " << to_string(effect);
LOG(ERROR) << "Receive " << to_string(available_effect);
}
}
if (have_invalid_order) {
LOG(ERROR) << "Have invalid effect order";
std::stable_sort(new_effects.begin(), new_effects.end(),
[](const Effect &lhs, const Effect &rhs) { return !lhs.is_sticker() && rhs.is_sticker(); });
}
message_effects_.effects_ = std::move(new_effects);
message_effects_.hash_ = effects->hash_;

View File

@ -202,6 +202,10 @@ class ReactionManager final : public Actor {
bool is_valid() const {
return id_ != 0 && effect_sticker_id_.is_valid();
}
bool is_sticker() const {
return effect_animation_id_ == FileId();
}
};
struct Effects {