Add hideSuggestedAction method.
GitOrigin-RevId: 11b162f37ab09c77bedae35157fc0870b2110795
This commit is contained in:
parent
454685efdf
commit
2e82c65d94
@ -3751,6 +3751,10 @@ getPollVoters chat_id:int53 message_id:int53 option_id:int32 offset:int32 limit:
|
||||
stopPoll chat_id:int53 message_id:int53 reply_markup:ReplyMarkup = Ok;
|
||||
|
||||
|
||||
//@description Hides a suggested action @action Suggested action to hide
|
||||
hideSuggestedAction action:SuggestedAction = Ok;
|
||||
|
||||
|
||||
//@description Returns information about a button of type inlineKeyboardButtonTypeLoginUrl. The method needs to be called when the user presses the button
|
||||
//@chat_id Chat identifier of the message with the button @message_id Message identifier of the message with the button @button_id Button identifier
|
||||
getLoginUrlInfo chat_id:int53 message_id:int53 button_id:int32 = LoginUrlInfo;
|
||||
|
Binary file not shown.
@ -1060,6 +1060,29 @@ td_api::object_ptr<td_api::updateSuggestedActions> ConfigManager::get_update_sug
|
||||
transform(removed_actions, get_suggested_action_object));
|
||||
}
|
||||
|
||||
void ConfigManager::dismiss_suggested_action(SuggestedAction suggested_action, Promise<Unit> &&promise) {
|
||||
if (suggested_action == SuggestedAction::Empty) {
|
||||
return promise.set_error(Status::Error(400, "Action must be non-empty"));
|
||||
}
|
||||
auto action_str = get_suggested_action_str(suggested_action);
|
||||
if (action_str.empty()) {
|
||||
return promise.set_value(Unit());
|
||||
}
|
||||
|
||||
if (!td::contains(suggested_actions_, suggested_action)) {
|
||||
return promise.set_value(Unit());
|
||||
}
|
||||
|
||||
dismiss_suggested_action_request_count_++;
|
||||
auto &queries = dismiss_suggested_action_queries_[suggested_action];
|
||||
queries.push_back(std::move(promise));
|
||||
if (queries.size() == 1) {
|
||||
G()->net_query_dispatcher().dispatch_with_callback(
|
||||
G()->net_query_creator().create(telegram_api::help_dismissSuggestion(action_str)),
|
||||
actor_shared(this, 100 + static_cast<int32>(suggested_action)));
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigManager::do_dismiss_suggested_action(SuggestedAction suggested_action) {
|
||||
if (td::remove(suggested_actions_, suggested_action)) {
|
||||
send_closure(G()->td(), &Td::send_update, get_update_suggested_actions({}, {suggested_action}));
|
||||
@ -1068,6 +1091,29 @@ void ConfigManager::do_dismiss_suggested_action(SuggestedAction suggested_action
|
||||
|
||||
void ConfigManager::on_result(NetQueryPtr res) {
|
||||
auto token = get_link_token();
|
||||
if (token >= 100 && token <= 200) {
|
||||
SuggestedAction suggested_action = static_cast<SuggestedAction>(static_cast<int32>(token - 100));
|
||||
auto promises = std::move(dismiss_suggested_action_queries_[suggested_action]);
|
||||
dismiss_suggested_action_queries_.erase(suggested_action);
|
||||
CHECK(!promises.empty());
|
||||
CHECK(dismiss_suggested_action_request_count_ >= promises.size());
|
||||
dismiss_suggested_action_request_count_ -= promises.size();
|
||||
|
||||
auto result_ptr = fetch_result<telegram_api::help_dismissSuggestion>(std::move(res));
|
||||
if (result_ptr.is_error()) {
|
||||
for (auto &promise : promises) {
|
||||
promise.set_error(result_ptr.error().clone());
|
||||
}
|
||||
return;
|
||||
}
|
||||
do_dismiss_suggested_action(suggested_action);
|
||||
get_app_config(Auto());
|
||||
|
||||
for (auto &promise : promises) {
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (token == 6 || token == 7) {
|
||||
is_set_archive_and_mute_request_sent_ = false;
|
||||
bool archive_and_mute = (token == 7);
|
||||
@ -1616,7 +1662,8 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
||||
shared_config.set_option_empty("default_ton_blockchain_config");
|
||||
shared_config.set_option_empty("default_ton_blockchain_name");
|
||||
|
||||
if (!is_set_content_settings_request_sent_) { // do not update suggested actions while changing content settings
|
||||
// do not update suggested actions while changing content settings or dismissing an action
|
||||
if (!is_set_content_settings_request_sent_ && dismiss_suggested_action_request_count_ == 0) {
|
||||
std::sort(suggested_actions.begin(), suggested_actions.end());
|
||||
suggested_actions.erase(std::unique(suggested_actions.begin(), suggested_actions.end()), suggested_actions.end());
|
||||
if (suggested_actions != suggested_actions_) {
|
||||
@ -1625,7 +1672,8 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
||||
auto old_it = suggested_actions_.begin();
|
||||
auto new_it = suggested_actions.begin();
|
||||
while (old_it != suggested_actions_.end() || new_it != suggested_actions.end()) {
|
||||
if (new_it == suggested_actions.end() || std::less<SuggestedAction>()(*old_it, *new_it)) {
|
||||
if (old_it != suggested_actions_.end() &&
|
||||
(new_it == suggested_actions.end() || std::less<SuggestedAction>()(*old_it, *new_it))) {
|
||||
removed_actions.push_back(*old_it++);
|
||||
} else if (old_it == suggested_actions_.end() || std::less<SuggestedAction>()(*new_it, *old_it)) {
|
||||
added_actions.push_back(*new_it++);
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "td/utils/Status.h"
|
||||
#include "td/utils/Time.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace td {
|
||||
|
||||
extern int VERBOSITY_NAME(config_recoverer);
|
||||
@ -95,6 +97,8 @@ class ConfigManager : public NetQueryCallback {
|
||||
|
||||
void set_archive_and_mute(bool archive_and_mute, Promise<Unit> &&promise);
|
||||
|
||||
void dismiss_suggested_action(SuggestedAction suggested_action, Promise<Unit> &&promise);
|
||||
|
||||
void on_dc_options_update(DcOptions dc_options);
|
||||
|
||||
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
||||
@ -119,6 +123,8 @@ class ConfigManager : public NetQueryCallback {
|
||||
bool last_set_archive_and_mute_ = false;
|
||||
|
||||
vector<SuggestedAction> suggested_actions_;
|
||||
size_t dismiss_suggested_action_request_count_ = 0;
|
||||
std::map<SuggestedAction, vector<Promise<Unit>>> dismiss_suggested_action_queries_;
|
||||
|
||||
void start_up() override;
|
||||
void hangup_shared() override;
|
||||
|
@ -83,6 +83,7 @@
|
||||
#include "td/telegram/StickerSetId.h"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
#include "td/telegram/StorageManager.h"
|
||||
#include "td/telegram/SuggestedAction.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/TopDialogCategory.h"
|
||||
#include "td/telegram/TopDialogManager.h"
|
||||
@ -7226,6 +7227,13 @@ void Td::on_request(uint64 id, td_api::stopPoll &request) {
|
||||
std::move(request.reply_markup_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::hideSuggestedAction &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
send_closure_later(config_manager_, &ConfigManager::dismiss_suggested_action, get_suggested_action(request.action_),
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getLoginUrlInfo &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
|
@ -941,6 +941,8 @@ class Td final : public NetQueryCallback {
|
||||
|
||||
void on_request(uint64 id, td_api::stopPoll &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::hideSuggestedAction &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getLoginUrlInfo &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getLoginUrl &request);
|
||||
|
@ -1194,6 +1194,16 @@ class CliClient final : public Actor {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static td_api::object_ptr<td_api::SuggestedAction> as_suggested_action(Slice action) {
|
||||
if (action == "unarchive") {
|
||||
return td_api::make_object<td_api::suggestedActionEnableArchiveAndMuteNewChats>();
|
||||
}
|
||||
if (action == "number") {
|
||||
return td_api::make_object<td_api::suggestedActionCheckPhoneNumber>();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static td_api::object_ptr<td_api::PassportElementType> as_passport_element_type(Slice passport_element_type) {
|
||||
if (passport_element_type == "address" || passport_element_type == "a") {
|
||||
return td_api::make_object<td_api::passportElementTypeAddress>();
|
||||
@ -3996,6 +4006,8 @@ class CliClient final : public Actor {
|
||||
|
||||
send_request(
|
||||
td_api::make_object<td_api::getChatStatisticsGraph>(as_chat_id(chat_id), token, to_integer<int64>(x)));
|
||||
} else if (op == "hsa" || op == "glu" || op == "glua") {
|
||||
send_request(td_api::make_object<td_api::hideSuggestedAction>(as_suggested_action(args)));
|
||||
} else if (op == "glui" || op == "glu" || op == "glua") {
|
||||
string chat_id;
|
||||
string message_id;
|
||||
|
Loading…
Reference in New Issue
Block a user