Move get_update_suggested_actions_object to SuggestedAction.cpp.

This commit is contained in:
levlam 2021-02-21 00:21:14 +03:00
parent c07a1dac22
commit a41bca4b0e
4 changed files with 14 additions and 12 deletions

View File

@ -1130,12 +1130,6 @@ void ConfigManager::do_set_archive_and_mute(bool archive_and_mute) {
G()->shared_config().set_option_boolean("archive_and_mute_new_chats_from_unknown_users", archive_and_mute);
}
td_api::object_ptr<td_api::updateSuggestedActions> ConfigManager::get_update_suggested_actions(
const vector<SuggestedAction> &added_actions, const vector<SuggestedAction> &removed_actions) {
return td_api::make_object<td_api::updateSuggestedActions>(transform(added_actions, get_suggested_action_object),
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"));
@ -1162,7 +1156,7 @@ void ConfigManager::dismiss_suggested_action(SuggestedAction suggested_action, P
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}));
send_closure(G()->td(), &Td::send_update, get_update_suggested_actions_object({}, {suggested_action}));
}
}
@ -1809,14 +1803,14 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
CHECK(!added_actions.empty() || !removed_actions.empty());
suggested_actions_ = std::move(suggested_actions);
send_closure(G()->td(), &Td::send_update,
get_update_suggested_actions(std::move(added_actions), std::move(removed_actions)));
get_update_suggested_actions_object(std::move(added_actions), std::move(removed_actions)));
}
}
}
void ConfigManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
if (!suggested_actions_.empty()) {
updates.push_back(get_update_suggested_actions(suggested_actions_, {}));
updates.push_back(get_update_suggested_actions_object(suggested_actions_, {}));
}
}

View File

@ -157,9 +157,6 @@ class ConfigManager : public NetQueryCallback {
void do_set_archive_and_mute(bool archive_and_mute);
static td_api::object_ptr<td_api::updateSuggestedActions> get_update_suggested_actions(
const vector<SuggestedAction> &added_actions, const vector<SuggestedAction> &removed_actions);
void do_dismiss_suggested_action(SuggestedAction suggested_action);
static Timestamp load_config_expire_time();

View File

@ -6,6 +6,8 @@
//
#include "td/telegram/SuggestedAction.h"
#include "td/utils/algorithm.h"
namespace td {
SuggestedAction get_suggested_action(Slice action_str) {
@ -62,4 +64,10 @@ td_api::object_ptr<td_api::SuggestedAction> get_suggested_action_object(Suggeste
}
}
td_api::object_ptr<td_api::updateSuggestedActions> get_update_suggested_actions_object(
const vector<SuggestedAction> &added_actions, const vector<SuggestedAction> &removed_actions) {
return td_api::make_object<td_api::updateSuggestedActions>(transform(added_actions, get_suggested_action_object),
transform(removed_actions, get_suggested_action_object));
}
} // namespace td

View File

@ -23,4 +23,7 @@ SuggestedAction get_suggested_action(const td_api::object_ptr<td_api::SuggestedA
td_api::object_ptr<td_api::SuggestedAction> get_suggested_action_object(SuggestedAction action);
td_api::object_ptr<td_api::updateSuggestedActions> get_update_suggested_actions_object(
const vector<SuggestedAction> &added_actions, const vector<SuggestedAction> &removed_actions);
} // namespace td