From c2a62dbc098a8cacc80dc25d9148800dcddbc11b Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 22 Aug 2022 15:23:17 +0300 Subject: [PATCH] Add updateDefaultReactionType. --- td/generate/scheme/td_api.tl | 5 ++++- td/telegram/MessageReaction.cpp | 10 ++++++++++ td/telegram/MessageReaction.h | 2 ++ td/telegram/OptionManager.cpp | 5 +++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index c0a3b20b0..045f75ea5 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -4476,6 +4476,9 @@ updateWebAppMessageSent web_app_launch_id:int64 = Update; //@description The list of supported reactions has changed @reactions The new list of supported reactions updateReactions reactions:vector = Update; +//@description The type of default reaction has changed @reaction_type The new type of the default reaction +updateDefaultReactionType reaction_type:ReactionType = Update; + //@description The list of supported dice emojis has changed @emojis The new list of supported dice emojis updateDiceEmojis emojis:vector = Update; @@ -5137,7 +5140,7 @@ setMessageReaction chat_id:int53 message_id:int53 reaction_type:ReactionType is_ //@limit The maximum number of reactions to be returned; must be positive and can't be greater than 100 getMessageAddedReactions chat_id:int53 message_id:int53 reaction_type:ReactionType offset:string limit:int32 = AddedReactions; -//@description Changes default reaction type for the current user @reaction_type New type of the default reaction +//@description Changes type of default reaction for the current user @reaction_type New type of the default reaction setDefaultReactionType reaction_type:ReactionType = Ok; diff --git a/td/telegram/MessageReaction.cpp b/td/telegram/MessageReaction.cpp index 1760a4888..3a5fefc1a 100644 --- a/td/telegram/MessageReaction.cpp +++ b/td/telegram/MessageReaction.cpp @@ -693,4 +693,14 @@ void send_set_default_reaction_query(Td *td) { td->create_handler()->send(td->option_manager_->get_option_string("default_reaction")); } +void send_update_default_reaction_type() { + auto default_reaction = G()->get_option_string("default_reaction"); + if (default_reaction.empty()) { + LOG(ERROR) << "Have no default reaction"; + return; + } + send_closure(G()->td(), &Td::send_update, + td_api::make_object(get_reaction_type_object(default_reaction))); +} + } // namespace td diff --git a/td/telegram/MessageReaction.h b/td/telegram/MessageReaction.h index bdb50b345..1191088b1 100644 --- a/td/telegram/MessageReaction.h +++ b/td/telegram/MessageReaction.h @@ -186,4 +186,6 @@ void set_default_reaction(Td *td, string reaction, Promise &&promise); void send_set_default_reaction_query(Td *td); +void send_update_default_reaction_type(); + } // namespace td diff --git a/td/telegram/OptionManager.cpp b/td/telegram/OptionManager.cpp index 88285224b..bf90751eb 100644 --- a/td/telegram/OptionManager.cpp +++ b/td/telegram/OptionManager.cpp @@ -65,6 +65,8 @@ OptionManager::OptionManager(Td *td) vector added_actions{SuggestedAction{SuggestedAction::Type::SetPassword, DialogId(), days}}; send_closure(G()->td(), &Td::send_update, get_update_suggested_actions_object(added_actions, {})); } + } else if (name == "default_reaction") { + send_update_default_reaction_type(); } } @@ -317,6 +319,9 @@ void OptionManager::on_option_updated(Slice name) { } break; case 'd': + if (name == "default_reaction") { + send_update_default_reaction_type(); + } if (name == "dice_emojis") { send_closure(td_->stickers_manager_actor_, &StickersManager::on_update_dice_emojis); }