Add td_api::deleteQuickReplyShortcut.
This commit is contained in:
parent
370d862acf
commit
44366bd208
@ -7732,6 +7732,9 @@ editMessageSchedulingState chat_id:int53 message_id:int53 scheduling_state:Messa
|
|||||||
//@description Loads quick reply shortcuts created by the current user. The loaded topics will be sent through updateQuickReplyShortcuts
|
//@description Loads quick reply shortcuts created by the current user. The loaded topics will be sent through updateQuickReplyShortcuts
|
||||||
loadQuickReplyShortcuts = Ok;
|
loadQuickReplyShortcuts = Ok;
|
||||||
|
|
||||||
|
//@description Deletes a quick reply shortcut @name The name of the quick reply shortcut
|
||||||
|
deleteQuickReplyShortcut name:string = Ok;
|
||||||
|
|
||||||
|
|
||||||
//@description Returns list of custom emojis, which can be used as forum topic icon by all users
|
//@description Returns list of custom emojis, which can be used as forum topic icon by all users
|
||||||
getForumTopicDefaultIcons = Stickers;
|
getForumTopicDefaultIcons = Stickers;
|
||||||
|
@ -58,6 +58,31 @@ class GetQuickRepliesQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DeleteQuickReplyShortcutQuery final : public Td::ResultHandler {
|
||||||
|
Promise<Unit> promise_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DeleteQuickReplyShortcutQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(int32 shortcut_id) {
|
||||||
|
send_query(G()->net_query_creator().create(telegram_api::messages_deleteQuickReplyShortcut(shortcut_id)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(BufferSlice packet) final {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::messages_deleteQuickReplyShortcut>(packet);
|
||||||
|
if (result_ptr.is_error()) {
|
||||||
|
return on_error(result_ptr.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
promise_.set_value(Unit());
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(Status status) final {
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
QuickReplyManager::QuickReplyMessage::~QuickReplyMessage() = default;
|
QuickReplyManager::QuickReplyMessage::~QuickReplyMessage() = default;
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
@ -655,6 +680,18 @@ int64 QuickReplyManager::get_shortcuts_hash() const {
|
|||||||
return get_vector_hash(numbers);
|
return get_vector_hash(numbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QuickReplyManager::delete_quick_reply_shortcut(const string &name, Promise<Unit> &&promise) {
|
||||||
|
auto s = get_shortcut(name);
|
||||||
|
if (s == nullptr) {
|
||||||
|
return promise.set_error(Status::Error(400, "Shortcut not found"));
|
||||||
|
}
|
||||||
|
auto shortcut_id = s->shortcut_id_;
|
||||||
|
td::remove_if(shortcuts_.shortcuts_,
|
||||||
|
[shortcut_id](const unique_ptr<Shortcut> &shortcut) { return shortcut->shortcut_id_ == shortcut_id; });
|
||||||
|
|
||||||
|
td_->create_handler<DeleteQuickReplyShortcutQuery>(std::move(promise))->send(shortcut_id);
|
||||||
|
}
|
||||||
|
|
||||||
QuickReplyManager::Shortcut *QuickReplyManager::get_shortcut(int32 shortcut_id) {
|
QuickReplyManager::Shortcut *QuickReplyManager::get_shortcut(int32 shortcut_id) {
|
||||||
if (!shortcuts_.are_inited_) {
|
if (!shortcuts_.are_inited_) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -667,6 +704,18 @@ QuickReplyManager::Shortcut *QuickReplyManager::get_shortcut(int32 shortcut_id)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QuickReplyManager::Shortcut *QuickReplyManager::get_shortcut(const string &name) {
|
||||||
|
if (!shortcuts_.are_inited_) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
for (auto &shortcut : shortcuts_.shortcuts_) {
|
||||||
|
if (shortcut->name_ == name) {
|
||||||
|
return shortcut.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void QuickReplyManager::sort_quick_reply_messages(vector<unique_ptr<QuickReplyMessage>> &messages) {
|
void QuickReplyManager::sort_quick_reply_messages(vector<unique_ptr<QuickReplyMessage>> &messages) {
|
||||||
std::sort(messages.begin(), messages.end(),
|
std::sort(messages.begin(), messages.end(),
|
||||||
[](const unique_ptr<QuickReplyMessage> &lhs, const unique_ptr<QuickReplyMessage> &rhs) {
|
[](const unique_ptr<QuickReplyMessage> &lhs, const unique_ptr<QuickReplyMessage> &rhs) {
|
||||||
|
@ -30,6 +30,8 @@ class QuickReplyManager final : public Actor {
|
|||||||
|
|
||||||
void get_quick_reply_shortcuts(Promise<Unit> &&promise);
|
void get_quick_reply_shortcuts(Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void delete_quick_reply_shortcut(const string &name, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void reload_quick_reply_shortcuts();
|
void reload_quick_reply_shortcuts();
|
||||||
|
|
||||||
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
||||||
@ -161,6 +163,8 @@ class QuickReplyManager final : public Actor {
|
|||||||
|
|
||||||
Shortcut *get_shortcut(int32 shortcut_id);
|
Shortcut *get_shortcut(int32 shortcut_id);
|
||||||
|
|
||||||
|
Shortcut *get_shortcut(const string &name);
|
||||||
|
|
||||||
static void sort_quick_reply_messages(vector<unique_ptr<QuickReplyMessage>> &messages);
|
static void sort_quick_reply_messages(vector<unique_ptr<QuickReplyMessage>> &messages);
|
||||||
|
|
||||||
using QuickReplyMessageUniqueId = std::pair<MessageId, int32>;
|
using QuickReplyMessageUniqueId = std::pair<MessageId, int32>;
|
||||||
|
@ -5765,6 +5765,12 @@ void Td::on_request(uint64 id, const td_api::loadQuickReplyShortcuts &request) {
|
|||||||
quick_reply_manager_->get_quick_reply_shortcuts(std::move(promise));
|
quick_reply_manager_->get_quick_reply_shortcuts(std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::deleteQuickReplyShortcut &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
quick_reply_manager_->delete_quick_reply_shortcut(request.name_, std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::getStory &request) {
|
void Td::on_request(uint64 id, const td_api::getStory &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_REQUEST_PROMISE();
|
CREATE_REQUEST_PROMISE();
|
||||||
|
@ -866,6 +866,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, const td_api::loadQuickReplyShortcuts &request);
|
void on_request(uint64 id, const td_api::loadQuickReplyShortcuts &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::deleteQuickReplyShortcut &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::getStory &request);
|
void on_request(uint64 id, const td_api::getStory &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::getChatsToSendStories &request);
|
void on_request(uint64 id, const td_api::getChatsToSendStories &request);
|
||||||
|
@ -4827,6 +4827,10 @@ class CliClient final : public Actor {
|
|||||||
as_message_scheduling_state(date)));
|
as_message_scheduling_state(date)));
|
||||||
} else if (op == "lqrs") {
|
} else if (op == "lqrs") {
|
||||||
send_request(td_api::make_object<td_api::loadQuickReplyShortcuts>());
|
send_request(td_api::make_object<td_api::loadQuickReplyShortcuts>());
|
||||||
|
} else if (op == "dqrs") {
|
||||||
|
string name;
|
||||||
|
get_args(args, name);
|
||||||
|
send_request(td_api::make_object<td_api::deleteQuickReplyShortcut>(name));
|
||||||
} else if (op == "gftdi") {
|
} else if (op == "gftdi") {
|
||||||
send_request(td_api::make_object<td_api::getForumTopicDefaultIcons>());
|
send_request(td_api::make_object<td_api::getForumTopicDefaultIcons>());
|
||||||
} else if (op == "cft") {
|
} else if (op == "cft") {
|
||||||
|
Loading…
Reference in New Issue
Block a user