Add td_api::getCustomEmojiReactionAnimations.

This commit is contained in:
levlam 2022-09-12 15:44:37 +03:00
parent a33eb5233c
commit de1ed3275f
6 changed files with 50 additions and 1 deletions

View File

@ -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<file> = 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

View File

@ -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<td_api::emojis>(std::move(emojis)));
}
void StickersManager::get_custom_emoji_reaction_generic_animations(
bool is_recursive, Promise<td_api::object_ptr<td_api::files>> &&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<td_api::files>());
}
pending_get_generic_animations_queries_.push_back(PromiseCreator::lambda(
[actor_id = actor_id(this), promise = std::move(promise)](Result<Unit> &&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<td_api::files>(std::move(files)));
}
void StickersManager::get_default_emoji_statuses(bool is_recursive,
Promise<td_api::object_ptr<td_api::emojiStatuses>> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());

View File

@ -103,6 +103,9 @@ class StickersManager final : public Actor {
void get_all_animated_emojis(bool is_recursive, Promise<td_api::object_ptr<td_api::emojis>> &&promise);
void get_custom_emoji_reaction_generic_animations(bool is_recursive,
Promise<td_api::object_ptr<td_api::files>> &&promise);
void get_default_emoji_statuses(bool is_recursive, Promise<td_api::object_ptr<td_api::emojiStatuses>> &&promise);
bool is_default_emoji_status(int64 custom_emoji_id);
@ -986,7 +989,7 @@ class StickersManager final : public Actor {
vector<Promise<Unit>> pending_get_animated_emoji_queries_;
vector<Promise<Unit>> pending_get_premium_gift_option_sticker_queries_;
vector<Promise<Unit>> pending_get_generic_animations_queries_;
vector<Promise<Unit>> pending_get_default_statuses_queries_;
double next_click_animated_emoji_message_time_ = 0;

View File

@ -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 =

View File

@ -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);

View File

@ -2240,6 +2240,8 @@ class CliClient final : public Actor {
string emoji;
get_args(args, emoji);
send_request(td_api::make_object<td_api::getEmojiReaction>(emoji));
} else if (op == "gcera") {
send_request(td_api::make_object<td_api::getCustomEmojiReactionAnimations>());
} else if (op == "gmar") {
ChatId chat_id;
MessageId message_id;