From de1ed3275f972fab34887307e112ad96a6722488 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 12 Sep 2022 15:44:37 +0300 Subject: [PATCH] Add td_api::getCustomEmojiReactionAnimations. --- td/generate/scheme/td_api.tl | 6 ++++++ td/telegram/StickersManager.cpp | 30 ++++++++++++++++++++++++++++++ td/telegram/StickersManager.h | 5 ++++- td/telegram/Td.cpp | 6 ++++++ td/telegram/Td.h | 2 ++ td/telegram/cli.cpp | 2 ++ 6 files changed, 50 insertions(+), 1 deletion(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index ed14f50c1..b3bf3a726 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -163,6 +163,9 @@ remoteFile id:string unique_id:string is_uploading_active:Bool is_uploading_comp //@remote Information about the remote copy of the file file id:int32 size:int53 expected_size:int53 local:localFile remote:remoteFile = File; +//@description Represents a list of files @files List of files +files files:vector = Files; + //@class InputFile @description Points to a file @@ -5166,6 +5169,9 @@ editMessageSchedulingState chat_id:int53 message_id:int53 scheduling_state:Messa //@description Returns information about a emoji reaction. Returns a 404 error if the reaction is not found @emoji Text representation of the reaction getEmojiReaction emoji:string = EmojiReaction; +//@description Returns TGS files with generic animations for custom emoji reactions +getCustomEmojiReactionAnimations = Files; + //@description Returns reactions, which can be added to a message. The list can change after updateActiveEmojiReactions, updateChatAvailableReactions for the chat, or updateMessageInteractionInfo for the message //@chat_id Identifier of the chat to which the message belongs //@message_id Identifier of the message diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index a4c2be352..5c9c02be8 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1678,6 +1678,7 @@ void StickersManager::on_load_special_sticker_set(const SpecialStickerSetType &t return; } if (type == SpecialStickerSetType::generic_animations()) { + set_promises(pending_get_generic_animations_queries_); return; } if (type == SpecialStickerSetType::default_statuses()) { @@ -5500,6 +5501,35 @@ void StickersManager::get_all_animated_emojis(bool is_recursive, promise.set_value(td_api::make_object(std::move(emojis))); } +void StickersManager::get_custom_emoji_reaction_generic_animations( + bool is_recursive, Promise> &&promise) { + TRY_STATUS_PROMISE(promise, G()->close_status()); + + auto &special_sticker_set = add_special_sticker_set(SpecialStickerSetType::generic_animations()); + auto sticker_set = get_sticker_set(special_sticker_set.id_); + if (sticker_set == nullptr || !sticker_set->was_loaded_) { + if (is_recursive) { + return promise.set_value(td_api::make_object()); + } + + pending_get_generic_animations_queries_.push_back(PromiseCreator::lambda( + [actor_id = actor_id(this), promise = std::move(promise)](Result &&result) mutable { + if (result.is_error()) { + promise.set_error(result.move_as_error()); + } else { + send_closure(actor_id, &StickersManager::get_custom_emoji_reaction_generic_animations, true, + std::move(promise)); + } + })); + load_special_sticker_set(special_sticker_set); + return; + } + + auto files = transform(sticker_set->sticker_ids_, + [&](FileId sticker_id) { return td_->file_manager_->get_file_object(sticker_id); }); + promise.set_value(td_api::make_object(std::move(files))); +} + void StickersManager::get_default_emoji_statuses(bool is_recursive, Promise> &&promise) { TRY_STATUS_PROMISE(promise, G()->close_status()); diff --git a/td/telegram/StickersManager.h b/td/telegram/StickersManager.h index 5e96746bd..5751cc15b 100644 --- a/td/telegram/StickersManager.h +++ b/td/telegram/StickersManager.h @@ -103,6 +103,9 @@ class StickersManager final : public Actor { void get_all_animated_emojis(bool is_recursive, Promise> &&promise); + void get_custom_emoji_reaction_generic_animations(bool is_recursive, + Promise> &&promise); + void get_default_emoji_statuses(bool is_recursive, Promise> &&promise); bool is_default_emoji_status(int64 custom_emoji_id); @@ -986,7 +989,7 @@ class StickersManager final : public Actor { vector> pending_get_animated_emoji_queries_; vector> pending_get_premium_gift_option_sticker_queries_; - + vector> pending_get_generic_animations_queries_; vector> pending_get_default_statuses_queries_; double next_click_animated_emoji_message_time_ = 0; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index e99fdd8eb..b5a9b6f7b 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -5204,6 +5204,12 @@ void Td::on_request(uint64 id, const td_api::getEmojiReaction &request) { send_closure(actor_id(this), &Td::send_result, id, stickers_manager_->get_emoji_reaction_object(request.emoji_)); } +void Td::on_request(uint64 id, const td_api::getCustomEmojiReactionAnimations &request) { + CHECK_IS_USER(); + CREATE_REQUEST_PROMISE(); + stickers_manager_->get_custom_emoji_reaction_generic_animations(false, std::move(promise)); +} + void Td::on_request(uint64 id, const td_api::getMessageAvailableReactions &request) { CHECK_IS_USER(); auto r_reactions = diff --git a/td/telegram/Td.h b/td/telegram/Td.h index e1e792a1a..433860e10 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -658,6 +658,8 @@ class Td final : public Actor { void on_request(uint64 id, const td_api::getEmojiReaction &request); + void on_request(uint64 id, const td_api::getCustomEmojiReactionAnimations &request); + void on_request(uint64 id, const td_api::getMessageAvailableReactions &request); void on_request(uint64 id, td_api::addMessageReaction &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index ea35247b0..1b9d08200 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2240,6 +2240,8 @@ class CliClient final : public Actor { string emoji; get_args(args, emoji); send_request(td_api::make_object(emoji)); + } else if (op == "gcera") { + send_request(td_api::make_object()); } else if (op == "gmar") { ChatId chat_id; MessageId message_id;