Add clean_phone_number.
This commit is contained in:
parent
ad22bf1174
commit
0939ad3db3
@ -8,6 +8,7 @@
|
||||
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/LanguagePackManager.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
@ -179,7 +180,7 @@ void CountryInfoManager::do_get_countries(string language_code, bool is_recursiv
|
||||
|
||||
void CountryInfoManager::get_phone_number_info(string phone_number_prefix,
|
||||
Promise<td_api::object_ptr<td_api::phoneNumberInfo>> &&promise) {
|
||||
td::remove_if(phone_number_prefix, [](char c) { return c < '0' || c > '9'; });
|
||||
clean_phone_number(phone_number_prefix);
|
||||
if (phone_number_prefix.empty()) {
|
||||
return promise.set_value(td_api::make_object<td_api::phoneNumberInfo>(nullptr, string(), string()));
|
||||
}
|
||||
@ -222,7 +223,7 @@ void CountryInfoManager::do_get_phone_number_info(string phone_number_prefix, st
|
||||
|
||||
td_api::object_ptr<td_api::phoneNumberInfo> CountryInfoManager::get_phone_number_info_sync(const string &language_code,
|
||||
string phone_number_prefix) {
|
||||
td::remove_if(phone_number_prefix, [](char c) { return !is_digit(c); });
|
||||
clean_phone_number(phone_number_prefix);
|
||||
if (phone_number_prefix.empty()) {
|
||||
return td_api::make_object<td_api::phoneNumberInfo>(nullptr, string(), string());
|
||||
}
|
||||
|
@ -51,6 +51,10 @@ string clean_username(string str) {
|
||||
return trim(str);
|
||||
}
|
||||
|
||||
void clean_phone_number(string &phone_number) {
|
||||
td::remove_if(phone_number, [](char c) { return !is_digit(c); });
|
||||
}
|
||||
|
||||
void replace_offending_characters(string &str) {
|
||||
// "(\xe2\x80\x8f|\xe2\x80\x8e){N}(\xe2\x80\x8f|\xe2\x80\x8e)" -> "(\xe2\x80\x8c){N}$2"
|
||||
auto s = MutableSlice(str).ubegin();
|
||||
|
@ -16,6 +16,9 @@ string clean_name(string str, size_t max_length) TD_WARN_UNUSED_RESULT;
|
||||
// prepares username/stickername for search
|
||||
string clean_username(string str) TD_WARN_UNUSED_RESULT;
|
||||
|
||||
// prepares phone number for search
|
||||
void clean_phone_number(string &phone_number);
|
||||
|
||||
// replaces some offending characters without changing string length
|
||||
void replace_offending_characters(string &str);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user