diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index fe195f4ab..2c82c4857 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -6604,7 +6604,7 @@ updateNewChatJoinRequest chat_id:int53 request:chatJoinRequest user_chat_id:int5 //@boost New information about the boost updateChatBoost chat_id:int53 boost:chatBoost = Update; -//@description User changed its reactions on a message; for bots only +//@description User changed its reactions on a message with public reactions; for bots only //@chat_id Chat identifier //@message_id Message identifier //@actor_id Identifier of the user or chat that changed reactions @@ -6613,6 +6613,13 @@ updateChatBoost chat_id:int53 boost:chatBoost = Update; //@new_reaction_types New list of chosen reactions updateMessageReaction chat_id:int53 message_id:int53 actor_id:MessageSender date:int32 old_reaction_types:vector new_reaction_types:vector = Update; +//@description Reactions added to a message with anonymous reactions have changed; for bots only +//@chat_id Chat identifier +//@message_id Message identifier +//@date Point in time (Unix timestamp) when the reactions were changed +//@reactions The list of reactions added to the message +updateMessageReactions chat_id:int53 message_id:int53 date:int32 reactions:vector = Update; + //@description Contains a list of updates @updates List of updates updates updates:vector = Updates; diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 8e3563000..cf92a4941 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -3033,6 +3033,33 @@ void UpdatesManager::process_qts_update(tl_object_ptr &&up ReactionType::get_reaction_types_object(new_reaction_types))); break; } + case telegram_api::updateBotMessageReactions::ID: { + auto update = move_tl_object_as(update_ptr); + auto dialog_id = DialogId(update->peer_); + auto message_id = MessageId(ServerMessageId(update->msg_id_)); + auto date = update->date_; + if (!dialog_id.is_valid() || !message_id.is_valid() || date <= 0) { + LOG(ERROR) << "Receive invalid " << to_string(update->reactions_); + return; + } + vector> message_reactions; + for (const auto &reaction_count : update->reactions_) { + auto reaction_type = ReactionType(reaction_count->reaction_); + if (reaction_type.is_empty() || reaction_count->count_ <= 0) { + LOG(ERROR) << "Receive invalid reaction in updateBotMessageReactions for " + << MessageFullId{dialog_id, message_id} << " at " << date << ": " << to_string(reaction_count); + continue; + } + message_reactions.push_back(td_api::make_object( + reaction_type.get_reaction_type_object(), reaction_count->count_, false, nullptr, Auto())); + } + td_->messages_manager_->force_create_dialog(dialog_id, "on_update_bot_message_reactions", true); + send_closure(G()->td(), &Td::send_update, + td_api::make_object( + td_->messages_manager_->get_chat_id_object(dialog_id, "updateMessageReactions"), + message_id.get(), date, std::move(message_reactions))); + break; + } default: UNREACHABLE(); break; @@ -3810,6 +3837,7 @@ bool UpdatesManager::is_qts_update(const telegram_api::Update *update) { case telegram_api::updateBotChatInviteRequester::ID: case telegram_api::updateBotChatBoost::ID: case telegram_api::updateBotMessageReaction::ID: + case telegram_api::updateBotMessageReactions::ID: return true; default: return false; @@ -3834,6 +3862,8 @@ int32 UpdatesManager::get_update_qts(const telegram_api::Update *update) { return static_cast(update)->qts_; case telegram_api::updateBotMessageReaction::ID: return static_cast(update)->qts_; + case telegram_api::updateBotMessageReactions::ID: + return static_cast(update)->qts_; default: return 0; } @@ -4317,6 +4347,11 @@ void UpdatesManager::on_update(tl_object_ptr update, Promise &&promise) { + auto qts = update->qts_; + add_pending_qts_update(std::move(update), qts, std::move(promise)); +} + void UpdatesManager::on_update(tl_object_ptr update, Promise &&promise) { td_->theme_manager_->on_update_theme(std::move(update->theme_), std::move(promise)); } @@ -4394,8 +4429,4 @@ void UpdatesManager::on_update(tl_object_ptr update, Promise &&promise) { - promise.set_value(Unit()); -} - } // namespace td diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index 06d922863..8ec5c3aa3 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -604,6 +604,7 @@ class UpdatesManager final : public Actor { void on_update(tl_object_ptr update, Promise &&promise); void on_update(tl_object_ptr update, Promise &&promise); void on_update(tl_object_ptr update, Promise &&promise); + void on_update(tl_object_ptr update, Promise &&promise); void on_update(tl_object_ptr update, Promise &&promise); @@ -632,8 +633,6 @@ class UpdatesManager final : public Actor { void on_update(tl_object_ptr update, Promise &&promise); // unsupported updates - - void on_update(tl_object_ptr update, Promise &&promise); }; } // namespace td