diff --git a/td/telegram/DialogAction.cpp b/td/telegram/DialogAction.cpp index 64f0ded56..bc562c656 100644 --- a/td/telegram/DialogAction.cpp +++ b/td/telegram/DialogAction.cpp @@ -21,11 +21,7 @@ bool DialogAction::is_valid_emoji(string &emoji) { if (!clean_input_string(emoji)) { return false; } - remove_emoji_modifiers_in_place(emoji); - if (emoji.empty()) { - return false; - } - return true; + return is_emoji(emoji); } void DialogAction::init(Type type) { diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 0e844447a..811113bee 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -5314,11 +5314,12 @@ void get_message_content_animated_emoji_click_sticker(const MessageContent *cont } void on_message_content_animated_emoji_clicked(const MessageContent *content, FullMessageId full_message_id, Td *td, - string emoji, string data) { + Slice emoji, string data) { if (content->get_type() != MessageContentType::Text) { return; } + emoji = remove_emoji_modifiers(emoji); auto &text = static_cast(content)->text; if (!text.entities.empty() || remove_emoji_modifiers(text.text) != emoji) { return; @@ -5559,9 +5560,10 @@ StickerSetId add_sticker_set(Td *td, tl_object_ptrstickers_manager_->is_sent_animated_emoji_click(dialog_id, emoji); + return !td->stickers_manager_->is_sent_animated_emoji_click(dialog_id, remove_emoji_modifiers(emoji)); } void on_dialog_used(TopDialogCategory category, DialogId dialog_id, int32 date) { diff --git a/td/telegram/MessageContent.h b/td/telegram/MessageContent.h index 83ce8c6ae..c046e6288 100644 --- a/td/telegram/MessageContent.h +++ b/td/telegram/MessageContent.h @@ -230,7 +230,7 @@ void get_message_content_animated_emoji_click_sticker(const MessageContent *cont Td *td, Promise> &&promise); void on_message_content_animated_emoji_clicked(const MessageContent *content, FullMessageId full_message_id, Td *td, - string emoji, string data); + Slice emoji, string data); bool need_reget_message_content(const MessageContent *content); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 8071fde9c..8ce8a313d 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -7106,7 +7106,7 @@ void MessagesManager::on_user_dialog_action(DialogId dialog_id, MessageId top_th auto message_id = MessageId(ServerMessageId(clicking_info.message_id)); CHECK(message_id.is_valid()); if (date > G()->unix_time() - 10) { - on_animated_emoji_message_clicked({dialog_id, message_id}, user_id, std::move(clicking_info.emoji), + on_animated_emoji_message_clicked({dialog_id, message_id}, user_id, clicking_info.emoji, std::move(clicking_info.data)); } return; @@ -19748,7 +19748,7 @@ void MessagesManager::click_animated_emoji_message(FullMessageId full_message_id get_message_content_animated_emoji_click_sticker(m->content.get(), full_message_id, td_, std::move(promise)); } -void MessagesManager::on_animated_emoji_message_clicked(FullMessageId full_message_id, UserId user_id, string emoji, +void MessagesManager::on_animated_emoji_message_clicked(FullMessageId full_message_id, UserId user_id, Slice emoji, string data) { CHECK(full_message_id.get_message_id().is_server()); auto *m = get_message_force(full_message_id, "on_animated_emoji_message_clicked"); @@ -19759,7 +19759,7 @@ void MessagesManager::on_animated_emoji_message_clicked(FullMessageId full_messa full_message_id.get_dialog_id().get_user_id() != user_id) { return; } - on_message_content_animated_emoji_clicked(m->content.get(), full_message_id, td_, std::move(emoji), std::move(data)); + on_message_content_animated_emoji_clicked(m->content.get(), full_message_id, td_, emoji, std::move(data)); } void MessagesManager::open_dialog(Dialog *d) { diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 71d03d6c2..39b82bb60 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -2964,7 +2964,7 @@ class MessagesManager final : public Actor { Status can_import_messages(DialogId dialog_id); - void on_animated_emoji_message_clicked(FullMessageId full_message_id, UserId user_id, string emoji, string data); + void on_animated_emoji_message_clicked(FullMessageId full_message_id, UserId user_id, Slice emoji, string data); void add_sponsored_dialog(const Dialog *d, DialogSource source); diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index cb8a0a103..f93493810 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -4241,7 +4241,7 @@ void StickersManager::flush_sent_animated_emoji_clicks() { sent_animated_emoji_clicks_.erase(sent_animated_emoji_clicks_.begin(), it); } -bool StickersManager::is_sent_animated_emoji_click(DialogId dialog_id, const string &emoji) { +bool StickersManager::is_sent_animated_emoji_click(DialogId dialog_id, Slice emoji) { flush_sent_animated_emoji_clicks(); for (const auto &click : sent_animated_emoji_clicks_) { if (click.dialog_id == dialog_id && click.emoji == emoji) { @@ -4251,8 +4251,7 @@ bool StickersManager::is_sent_animated_emoji_click(DialogId dialog_id, const str return false; } -Status StickersManager::on_animated_emoji_message_clicked(const string &emoji, FullMessageId full_message_id, - string data) { +Status StickersManager::on_animated_emoji_message_clicked(Slice emoji, FullMessageId full_message_id, string data) { TRY_RESULT(value, json_decode(data)); if (value.type() != JsonValue::Type::Object) { return Status::Error("Expected an object"); @@ -4313,7 +4312,7 @@ Status StickersManager::on_animated_emoji_message_clicked(const string &emoji, F } PendingOnAnimatedEmojiClicked pending_request; - pending_request.emoji_ = emoji; + pending_request.emoji_ = emoji.str(); pending_request.full_message_id_ = full_message_id; pending_request.clicks_ = std::move(clicks); pending_on_animated_emoji_message_clicked_.push_back(std::move(pending_request)); diff --git a/td/telegram/StickersManager.h b/td/telegram/StickersManager.h index ab92575cc..1b1239f07 100644 --- a/td/telegram/StickersManager.h +++ b/td/telegram/StickersManager.h @@ -73,9 +73,9 @@ class StickersManager final : public Actor { void on_send_animated_emoji_clicks(DialogId dialog_id, const string &emoji); - bool is_sent_animated_emoji_click(DialogId dialog_id, const string &emoji); + bool is_sent_animated_emoji_click(DialogId dialog_id, Slice emoji); - Status on_animated_emoji_message_clicked(const string &emoji, FullMessageId full_message_id, string data); + Status on_animated_emoji_message_clicked(Slice emoji, FullMessageId full_message_id, string data); void create_sticker(FileId file_id, string minithumbnail, PhotoSize thumbnail, Dimensions dimensions, tl_object_ptr sticker, bool is_animated,