Process fragment_prefixes option.
This commit is contained in:
parent
91a7399c27
commit
7e88119c1f
@ -13,6 +13,7 @@
|
||||
#include "td/telegram/LinkManager.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
#include "td/telegram/MessageReaction.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/net/AuthDataShared.h"
|
||||
#include "td/telegram/net/ConnectionCreator.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
@ -1493,6 +1494,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
||||
int32 stickers_normal_by_emoji_per_premium_num = 2;
|
||||
int32 forum_upgrade_participants_min = 200;
|
||||
int32 telegram_antispam_group_size_min = 100;
|
||||
vector<string> fragment_prefixes;
|
||||
if (config->get_id() == telegram_api::jsonObject::ID) {
|
||||
for (auto &key_value : static_cast<telegram_api::jsonObject *>(config.get())->value_) {
|
||||
Slice key = key_value->key_;
|
||||
@ -1858,6 +1860,23 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
||||
telegram_antispam_group_size_min = get_json_value_int(std::move(key_value->value_), key);
|
||||
continue;
|
||||
}
|
||||
if (key == "fragment_prefixes") {
|
||||
if (value->get_id() == telegram_api::jsonArray::ID) {
|
||||
auto prefixes = std::move(static_cast<telegram_api::jsonArray *>(value)->value_);
|
||||
for (auto &prefix : prefixes) {
|
||||
auto prefix_text = get_json_value_string(std::move(prefix), key);
|
||||
clean_phone_number(prefix_text);
|
||||
if (!prefix_text.empty()) {
|
||||
fragment_prefixes.push_back(prefix_text);
|
||||
} else {
|
||||
LOG(ERROR) << "Receive an invalid Fragment prefix";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG(ERROR) << "Receive unexpected fragment_prefixes " << to_string(*value);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
new_values.push_back(std::move(key_value));
|
||||
}
|
||||
@ -1906,6 +1925,8 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
||||
options.set_option_string("dice_emojis", implode(dice_emojis, '\x01'));
|
||||
}
|
||||
|
||||
options.set_option_string("fragment_prefixes", implode(fragment_prefixes, ','));
|
||||
|
||||
options.set_option_string("emoji_sounds", implode(emoji_sounds, ','));
|
||||
|
||||
if (animated_emoji_zoom <= 0 || animated_emoji_zoom > 2.0) {
|
||||
|
@ -3791,6 +3791,8 @@ void ContactsManager::start_up() {
|
||||
if (!pending_location_visibility_expire_date_) {
|
||||
try_send_set_location_visibility_query();
|
||||
}
|
||||
|
||||
on_update_fragment_prefixes();
|
||||
}
|
||||
|
||||
void ContactsManager::tear_down() {
|
||||
@ -16888,6 +16890,22 @@ void ContactsManager::on_update_channel_administrator_count(ChannelId channel_id
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_fragment_prefixes() {
|
||||
if (G()->close_flag()) {
|
||||
return;
|
||||
}
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto fragment_prefixes_str = td_->option_manager_->get_option_string("fragment_prefixes", "888");
|
||||
if (fragment_prefixes_str == fragment_prefixes_str_) {
|
||||
return;
|
||||
}
|
||||
fragment_prefixes_str_ = std::move(fragment_prefixes_str);
|
||||
fragment_prefixes_ = full_split(fragment_prefixes_str_, ',');
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_dialog_administrators(DialogId dialog_id, vector<DialogAdministrator> &&administrators,
|
||||
bool have_access, bool from_database) {
|
||||
LOG(INFO) << "Update administrators in " << dialog_id << " to " << format::as_array(administrators);
|
||||
|
@ -233,6 +233,8 @@ class ContactsManager final : public Actor {
|
||||
|
||||
void on_update_bot_menu_button(UserId bot_user_id, tl_object_ptr<telegram_api::BotMenuButton> &&bot_menu_button);
|
||||
|
||||
void on_update_fragment_prefixes();
|
||||
|
||||
void on_update_dialog_administrators(DialogId dialog_id, vector<DialogAdministrator> &&administrators,
|
||||
bool have_access, bool from_database);
|
||||
|
||||
@ -1930,6 +1932,9 @@ class ContactsManager final : public Actor {
|
||||
vector<UserId> imported_contact_user_ids_; // result of change_imported_contacts
|
||||
vector<int32> unimported_contact_invites_; // result of change_imported_contacts
|
||||
|
||||
string fragment_prefixes_str_;
|
||||
vector<string> fragment_prefixes_;
|
||||
|
||||
MultiTimeout user_online_timeout_{"UserOnlineTimeout"};
|
||||
MultiTimeout user_emoji_status_timeout_{"UserEmojiStatusTimeout"};
|
||||
MultiTimeout channel_unban_timeout_{"ChannelUnbanTimeout"};
|
||||
|
@ -264,6 +264,8 @@ bool OptionManager::is_internal_option(Slice name) {
|
||||
name == "dice_emojis" || name == "dice_success_values";
|
||||
case 'e':
|
||||
return name == "edit_time_limit" || name == "emoji_sounds";
|
||||
case 'f':
|
||||
return name == "fragment_prefixes";
|
||||
case 'i':
|
||||
return name == "ignored_restriction_reasons";
|
||||
case 'l':
|
||||
@ -360,6 +362,9 @@ void OptionManager::on_option_updated(Slice name) {
|
||||
if (name == "favorite_stickers_limit") {
|
||||
td_->stickers_manager_->on_update_favorite_stickers_limit();
|
||||
}
|
||||
if (name == "fragment_prefixes") {
|
||||
send_closure(td_->contacts_manager_actor_, &ContactsManager::on_update_fragment_prefixes);
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
if (name == "ignored_restriction_reasons") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user