Add td_api::getCustomEmojiStickers.
This commit is contained in:
parent
ba3f24ed8d
commit
771b6d3991
@ -5972,6 +5972,9 @@ getAnimatedEmoji emoji:string = AnimatedEmoji;
|
||||
//@description Returns an HTTP URL which can be used to automatically log in to the translation platform and suggest new emoji replacements. The URL will be valid for 30 seconds after generation @language_code Language code for which the emoji replacements will be suggested
|
||||
getEmojiSuggestionsUrl language_code:string = HttpUrl;
|
||||
|
||||
//@description Returns list of custom emoji stickers by their identifiers. Stickers are returned in arbitrary order. Only found stickers are returned @custom_emoji_ids Identifiers of custom emoji stickers
|
||||
getCustomEmojiStickers custom_emoji_ids:vector<int64> = Stickers;
|
||||
|
||||
|
||||
//@description Returns saved animations
|
||||
getSavedAnimations = Animations;
|
||||
|
@ -1210,6 +1210,33 @@ class DeleteStickerFromSetQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class GetCustomEmojiDocumentsQuery final : public Td::ResultHandler {
|
||||
Promise<vector<telegram_api::object_ptr<telegram_api::Document>>> promise_;
|
||||
|
||||
public:
|
||||
explicit GetCustomEmojiDocumentsQuery(Promise<vector<telegram_api::object_ptr<telegram_api::Document>>> &&promise)
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(vector<int64> &&document_ids) {
|
||||
send_query(
|
||||
G()->net_query_creator().create(telegram_api::messages_getCustomEmojiDocuments(std::move(document_ids))));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::messages_getCustomEmojiDocuments>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
promise_.set_value(result_ptr.move_as_ok());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class SendAnimatedEmojiClicksQuery final : public Td::ResultHandler {
|
||||
DialogId dialog_id_;
|
||||
string emoji_;
|
||||
@ -4928,6 +4955,41 @@ 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_stickers(vector<int64> &&document_ids,
|
||||
Promise<td_api::object_ptr<td_api::stickers>> &&promise) {
|
||||
auto query_promise =
|
||||
PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise)](
|
||||
Result<vector<telegram_api::object_ptr<telegram_api::Document>>> r_documents) mutable {
|
||||
send_closure(actor_id, &StickersManager::on_get_custom_emoji_documents, std::move(r_documents),
|
||||
std::move(promise));
|
||||
});
|
||||
td_->create_handler<GetCustomEmojiDocumentsQuery>(std::move(query_promise))->send(std::move(document_ids));
|
||||
}
|
||||
|
||||
void StickersManager::on_get_custom_emoji_documents(
|
||||
Result<vector<telegram_api::object_ptr<telegram_api::Document>>> r_documents,
|
||||
Promise<td_api::object_ptr<td_api::stickers>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
if (r_documents.is_error()) {
|
||||
return promise.set_error(r_documents.move_as_error());
|
||||
}
|
||||
auto documents = r_documents.move_as_ok();
|
||||
|
||||
vector<td_api::object_ptr<td_api::sticker>> stickers;
|
||||
for (auto &document : documents) {
|
||||
std::pair<int64, FileId> sticker_info = on_get_sticker_document(std::move(document), StickerFormat::Unknown);
|
||||
auto sticker = get_sticker_object(sticker_info.second);
|
||||
if (sticker == nullptr) {
|
||||
LOG(ERROR) << "Receive an invalid custom emoji sticker";
|
||||
continue;
|
||||
}
|
||||
|
||||
stickers.push_back(std::move(sticker));
|
||||
}
|
||||
|
||||
promise.set_value(td_api::make_object<td_api::stickers>(std::move(stickers)));
|
||||
}
|
||||
|
||||
void StickersManager::get_premium_gift_option_sticker(int32 month_count, bool is_recursive,
|
||||
Promise<td_api::object_ptr<td_api::sticker>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
|
@ -93,6 +93,8 @@ 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_stickers(vector<int64> &&document_ids, Promise<td_api::object_ptr<td_api::stickers>> &&promise);
|
||||
|
||||
void get_premium_gift_option_sticker(int32 month_count, bool is_recursive,
|
||||
Promise<td_api::object_ptr<td_api::sticker>> &&promise);
|
||||
|
||||
@ -763,6 +765,9 @@ class StickersManager final : public Actor {
|
||||
|
||||
static void add_sticker_thumbnail(Sticker *s, PhotoSize thumbnail);
|
||||
|
||||
void on_get_custom_emoji_documents(Result<vector<telegram_api::object_ptr<telegram_api::Document>>> r_documents,
|
||||
Promise<td_api::object_ptr<td_api::stickers>> &&promise);
|
||||
|
||||
static string get_emoji_language_code_version_database_key(const string &language_code);
|
||||
|
||||
static string get_emoji_language_code_last_difference_time_database_key(const string &language_code);
|
||||
|
@ -7181,6 +7181,11 @@ void Td::on_request(uint64 id, td_api::getEmojiSuggestionsUrl &request) {
|
||||
CREATE_REQUEST(GetEmojiSuggestionsUrlRequest, std::move(request.language_code_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getCustomEmojiStickers &request) {
|
||||
CREATE_REQUEST_PROMISE();
|
||||
stickers_manager_->get_custom_emoji_stickers(std::move(request.custom_emoji_ids_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getSavedAnimations &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_NO_ARGS_REQUEST(GetSavedAnimationsRequest);
|
||||
|
@ -1117,6 +1117,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::getEmojiSuggestionsUrl &request);
|
||||
|
||||
void on_request(uint64 id, td_api::getCustomEmojiStickers &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getFavoriteStickers &request);
|
||||
|
||||
void on_request(uint64 id, td_api::addFavoriteSticker &request);
|
||||
|
@ -2791,6 +2791,8 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::getAnimatedEmoji>(args));
|
||||
} else if (op == "gesu") {
|
||||
send_request(td_api::make_object<td_api::getEmojiSuggestionsUrl>(args));
|
||||
} else if (op == "gces") {
|
||||
send_request(td_api::make_object<td_api::getCustomEmojiStickers>(to_integers<int64>(args)));
|
||||
} else if (op == "gpgos") {
|
||||
send_request(td_api::make_object<td_api::getPremiumGiftOptionSticker>(to_integer<int32>(args)));
|
||||
} else if (op == "gsan") {
|
||||
|
Loading…
Reference in New Issue
Block a user