Add suggestedActionCheckPhoneNumber support.

This commit is contained in:
levlam 2021-06-11 02:13:46 +03:00
parent b60c443edd
commit c4dab736c9
4 changed files with 14 additions and 0 deletions

View File

@ -1074,6 +1074,10 @@ 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);
}
void ConfigManager::hide_suggested_action(SuggestedAction suggested_action) {
remove_suggested_action(suggested_actions_, suggested_action);
}
void ConfigManager::dismiss_suggested_action(SuggestedAction suggested_action, Promise<Unit> &&promise) {
auto action_str = suggested_action.get_suggested_action_str();
if (action_str.empty()) {

View File

@ -101,6 +101,8 @@ class ConfigManager : public NetQueryCallback {
void set_archive_and_mute(bool archive_and_mute, Promise<Unit> &&promise);
void hide_suggested_action(SuggestedAction suggested_action);
void dismiss_suggested_action(SuggestedAction suggested_action, Promise<Unit> &&promise);
void on_dc_options_update(DcOptions dc_options);

View File

@ -6,8 +6,10 @@
//
#include "td/telegram/PhoneNumberManager.h"
#include "td/telegram/ConfigManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/SuggestedAction.h"
#include "td/telegram/Td.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
@ -48,6 +50,8 @@ void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number,
switch (type_) {
case Type::ChangePhone:
send_closure(G()->config_manager(), &ConfigManager::hide_suggested_action,
SuggestedAction{SuggestedAction::Type::CheckPhoneNumber});
return process_send_code_result(query_id, send_code_helper_.send_change_phone_code(phone_number, settings));
case Type::VerifyPhone:
return process_send_code_result(query_id, send_code_helper_.send_verify_phone_code(phone_number, settings));

View File

@ -25,6 +25,8 @@ void SuggestedAction::init(Type type) {
SuggestedAction::SuggestedAction(Slice action_str) {
if (action_str == Slice("AUTOARCHIVE_POPULAR")) {
init(Type::EnableArchiveAndMuteNewChats);
} else if (action_str == Slice("VALIDATE_PHONE_NUMBER")) {
init(Type::CheckPhoneNumber);
} else if (action_str == Slice("NEWCOMER_TICKS")) {
init(Type::SeeTicksHint);
}
@ -70,6 +72,8 @@ string SuggestedAction::get_suggested_action_str() const {
switch (type_) {
case Type::EnableArchiveAndMuteNewChats:
return "AUTOARCHIVE_POPULAR";
case Type::CheckPhoneNumber:
return "VALIDATE_PHONE_NUMBER";
case Type::SeeTicksHint:
return "NEWCOMER_TICKS";
case Type::ConvertToGigagroup: