Move dismiss_suggested_action to SuggestedAction.cpp.
This commit is contained in:
parent
c49c5954ed
commit
25baedaa34
@ -7594,17 +7594,8 @@ void ContactsManager::remove_dialog_suggested_action(SuggestedAction action) {
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::dismiss_suggested_action(SuggestedAction action, Promise<Unit> &&promise) {
|
||||
if (action.is_empty()) {
|
||||
return promise.set_error(Status::Error(400, "Action must be non-empty"));
|
||||
}
|
||||
void ContactsManager::dismiss_dialog_suggested_action(SuggestedAction action, Promise<Unit> &&promise) {
|
||||
auto dialog_id = action.dialog_id_;
|
||||
if (dialog_id == DialogId()) {
|
||||
send_closure_later(G()->config_manager(), &ConfigManager::dismiss_suggested_action, std::move(action),
|
||||
std::move(promise));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!td_->messages_manager_->have_dialog(dialog_id)) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
|
@ -418,7 +418,7 @@ class ContactsManager final : public Actor {
|
||||
|
||||
vector<DialogId> get_inactive_channels(Promise<Unit> &&promise);
|
||||
|
||||
void dismiss_suggested_action(SuggestedAction action, Promise<Unit> &&promise);
|
||||
void dismiss_dialog_suggested_action(SuggestedAction action, Promise<Unit> &&promise);
|
||||
|
||||
bool is_user_contact(UserId user_id, bool is_mutual = false) const;
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "td/telegram/SuggestedAction.h"
|
||||
|
||||
#include "td/telegram/ChannelId.h"
|
||||
#include "td/telegram/ConfigManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/Td.h"
|
||||
|
||||
@ -151,4 +153,23 @@ void remove_suggested_action(vector<SuggestedAction> &suggested_actions, Suggest
|
||||
}
|
||||
}
|
||||
|
||||
void dismiss_suggested_action(SuggestedAction action, Promise<Unit> &&promise) {
|
||||
switch (action.type_) {
|
||||
case SuggestedAction::Type::Empty:
|
||||
return promise.set_error(Status::Error(400, "Action must be non-empty"));
|
||||
case SuggestedAction::Type::EnableArchiveAndMuteNewChats:
|
||||
case SuggestedAction::Type::CheckPassword:
|
||||
case SuggestedAction::Type::CheckPhoneNumber:
|
||||
case SuggestedAction::Type::SeeTicksHint:
|
||||
return send_closure_later(G()->config_manager(), &ConfigManager::dismiss_suggested_action, std::move(action),
|
||||
std::move(promise));
|
||||
case SuggestedAction::Type::ConvertToGigagroup:
|
||||
return send_closure_later(G()->contacts_manager(), &ContactsManager::dismiss_dialog_suggested_action,
|
||||
std::move(action), std::move(promise));
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
|
||||
#include "td/actor/PromiseFuture.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/Slice.h"
|
||||
|
||||
@ -70,4 +72,6 @@ void update_suggested_actions(vector<SuggestedAction> &suggested_actions,
|
||||
|
||||
void remove_suggested_action(vector<SuggestedAction> &suggested_actions, SuggestedAction suggested_action);
|
||||
|
||||
void dismiss_suggested_action(SuggestedAction action, Promise<Unit> &&promise);
|
||||
|
||||
} // namespace td
|
||||
|
@ -7643,7 +7643,7 @@ void Td::on_request(uint64 id, td_api::stopPoll &request) {
|
||||
void Td::on_request(uint64 id, const td_api::hideSuggestedAction &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->dismiss_suggested_action(SuggestedAction(request.action_), std::move(promise));
|
||||
dismiss_suggested_action(SuggestedAction(request.action_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getLoginUrlInfo &request) {
|
||||
|
Loading…
Reference in New Issue
Block a user