diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index d84b82130..fdb6ba92f 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3777,9 +3777,6 @@ storyInteractions total_count:int32 total_forward_count:int32 total_reaction_cou //@content Content of the message quickReplyMessage id:int53 sending_state:MessageSendingState can_be_edited:Bool reply_to_message_id:int53 via_bot_user_id:int53 media_album_id:int64 content:MessageContent = QuickReplyMessage; -//@description Contains a list of quick reply messages @messages List of messages -quickReplyMessages messages:vector = QuickReplyMessages; - //@description Describes a shortcut that can be used for a quick reply //@id Unique shortcut identifier //@name The name of the shortcut that can be used to use the shortcut @@ -6645,7 +6642,9 @@ updateQuickReplyShortcutDeleted shortcut_id:int32 = Update; //@description The list of quick reply shortcuts has changed @shortcut_ids The new list of identifiers of quick reply shortcuts updateQuickReplyShortcuts shortcut_ids:vector = Update; -//@description The list of quick reply shortcut messages has changed @shortcut_id The identifier of the shortcut @messages The new list of quick reply messages for the shortcut +//@description The list of quick reply shortcut messages has changed +//@shortcut_id The identifier of the shortcut +//@messages The new list of quick reply messages for the shortcut in order from the first to the last sent updateQuickReplyShortcutMessages shortcut_id:int32 messages:vector = Update; //@description Basic information about a topic in a forum chat was changed @chat_id Chat identifier @info New information about the topic @@ -7784,8 +7783,9 @@ deleteQuickReplyShortcut shortcut_id:int32 = Ok; //@description Changes the order of quick reply shortcuts @shortcut_ids The new order of quick reply shortcuts reorderQuickReplyShortcuts shortcut_ids:vector = Ok; -//@description Returns all messages that can be sent by a quick reply shortcut. The messages are returned in order from the first to the last sent @shortcut_id Unique identifier of the quick reply shortcut -getQuickReplyShortcutMessages shortcut_id:int32 = QuickReplyMessages; +//@description Loads quick reply messages that can be sent by a given quick reply shortcut. The loaded messages will be sent through updateQuickReplyShortcutMessages +//@shortcut_id Unique identifier of the quick reply shortcut +loadQuickReplyShortcutMessages shortcut_id:int32 = Ok; //@description Returns list of custom emojis, which can be used as forum topic icon by all users diff --git a/td/telegram/QuickReplyManager.cpp b/td/telegram/QuickReplyManager.cpp index e4ad3428c..4fdf3761f 100644 --- a/td/telegram/QuickReplyManager.cpp +++ b/td/telegram/QuickReplyManager.cpp @@ -850,22 +850,20 @@ void QuickReplyManager::delete_quick_reply_messages(QuickReplyShortcutId shortcu } } -void QuickReplyManager::get_quick_reply_shortcut_messages( - QuickReplyShortcutId shortcut_id, Promise> &&promise) { +void QuickReplyManager::get_quick_reply_shortcut_messages(QuickReplyShortcutId shortcut_id, Promise &&promise) { auto s = get_shortcut(shortcut_id); if (s == nullptr) { return promise.set_error(Status::Error(400, "Shortcut not found")); } if (have_all_shortcut_messages(s)) { - return promise.set_value(get_quick_reply_messages_object(s)); + return promise.set_value(Unit()); } CHECK(shortcut_id.is_server()); reload_quick_reply_messages(shortcut_id, std::move(promise)); } -void QuickReplyManager::reload_quick_reply_messages(QuickReplyShortcutId shortcut_id, - Promise> &&promise) { +void QuickReplyManager::reload_quick_reply_messages(QuickReplyShortcutId shortcut_id, Promise &&promise) { auto &queries = get_shortcut_messages_queries_[shortcut_id]; queries.push_back(std::move(promise)); if (queries.size() != 1) { @@ -955,9 +953,7 @@ void QuickReplyManager::on_reload_quick_reply_messages( return fail_promises(promises, Status::Error(400, "Shortcut not found")); } for (auto &promise : promises) { - if (promise) { - promise.set_value(get_quick_reply_messages_object(s)); - } + promise.set_value(Unit()); } } @@ -1155,14 +1151,6 @@ void QuickReplyManager::send_update_quick_reply_shortcuts() { send_closure(G()->td(), &Td::send_update, get_update_quick_reply_shortcuts_object()); } -td_api::object_ptr QuickReplyManager::get_quick_reply_messages_object( - const Shortcut *s) const { - auto messages = transform(s->messages_, [this](const unique_ptr &message) { - return get_quick_reply_message_object(message.get(), "get_quick_reply_messages_object"); - }); - return td_api::make_object(std::move(messages)); -} - td_api::object_ptr QuickReplyManager::get_update_quick_reply_shortcut_messages_object(const Shortcut *s) const { CHECK(s != nullptr); diff --git a/td/telegram/QuickReplyManager.h b/td/telegram/QuickReplyManager.h index f2ea81fe7..153fdbc6b 100644 --- a/td/telegram/QuickReplyManager.h +++ b/td/telegram/QuickReplyManager.h @@ -39,8 +39,7 @@ class QuickReplyManager final : public Actor { void delete_quick_reply_messages(QuickReplyShortcutId shortcut_id, const vector &message_ids); - void get_quick_reply_shortcut_messages(QuickReplyShortcutId shortcut_id, - Promise> &&promise); + void get_quick_reply_shortcut_messages(QuickReplyShortcutId shortcut_id, Promise &&promise); void reload_quick_reply_shortcuts(); @@ -167,8 +166,7 @@ class QuickReplyManager final : public Actor { int64 get_shortcuts_hash() const; - void reload_quick_reply_messages(QuickReplyShortcutId shortcut_id, - Promise> &&promise); + void reload_quick_reply_messages(QuickReplyShortcutId shortcut_id, Promise &&promise); void on_reload_quick_reply_messages(QuickReplyShortcutId shortcut_id, Result> r_messages); @@ -220,8 +218,6 @@ class QuickReplyManager final : public Actor { void send_update_quick_reply_shortcuts(); - td_api::object_ptr get_quick_reply_messages_object(const Shortcut *s) const; - td_api::object_ptr get_update_quick_reply_shortcut_messages_object( const Shortcut *s) const; @@ -239,9 +235,7 @@ class QuickReplyManager final : public Actor { FlatHashSet deleted_shortcut_ids_; - FlatHashMap>>, - QuickReplyShortcutIdHash> - get_shortcut_messages_queries_; + FlatHashMap>, QuickReplyShortcutIdHash> get_shortcut_messages_queries_; Td *td_; ActorShared<> parent_; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 72bf38f62..b780caa31 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -5780,9 +5780,9 @@ void Td::on_request(uint64 id, const td_api::reorderQuickReplyShortcuts &request QuickReplyShortcutId::get_quick_reply_shortcut_ids(request.shortcut_ids_), std::move(promise)); } -void Td::on_request(uint64 id, const td_api::getQuickReplyShortcutMessages &request) { +void Td::on_request(uint64 id, const td_api::loadQuickReplyShortcutMessages &request) { CHECK_IS_USER(); - CREATE_REQUEST_PROMISE(); + CREATE_OK_REQUEST_PROMISE(); quick_reply_manager_->get_quick_reply_shortcut_messages(QuickReplyShortcutId(request.shortcut_id_), std::move(promise)); } diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 2eb704fa5..e2b3d72ac 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -870,7 +870,7 @@ class Td final : public Actor { void on_request(uint64 id, const td_api::reorderQuickReplyShortcuts &request); - void on_request(uint64 id, const td_api::getQuickReplyShortcutMessages &request); + void on_request(uint64 id, const td_api::loadQuickReplyShortcutMessages &request); void on_request(uint64 id, const td_api::getStory &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 6560f9383..863193768 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -4855,10 +4855,10 @@ class CliClient final : public Actor { string shortcut_ids; get_args(args, shortcut_ids); send_request(td_api::make_object(as_shortcut_ids(shortcut_ids))); - } else if (op == "gqrsm") { + } else if (op == "lqrsm") { ShortcutId shortcut_id; get_args(args, shortcut_id); - send_request(td_api::make_object(shortcut_id)); + send_request(td_api::make_object(shortcut_id)); } else if (op == "gftdi") { send_request(td_api::make_object()); } else if (op == "cft") {