Make option "anti_spam_bot_user_id" public and allow to load the user without network request.
This commit is contained in:
parent
1ba66081a5
commit
bc332ffa37
@ -1853,7 +1853,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
||||
}
|
||||
if (key == "telegram_antispam_user_id") {
|
||||
auto setting_value = get_json_value_long(std::move(key_value->value_), key);
|
||||
G()->set_option_integer("telegram_antispam_user_id", setting_value);
|
||||
G()->set_option_integer("anti_spam_bot_user_id", setting_value);
|
||||
continue;
|
||||
}
|
||||
if (key == "telegram_antispam_group_size_min") {
|
||||
|
@ -3712,6 +3712,9 @@ ContactsManager::ContactsManager(Td *td, ActorShared<> parent) : td_(td), parent
|
||||
td_->option_manager_->set_option_integer("replies_bot_chat_id", DialogId(get_replies_bot_user_id()).get());
|
||||
td_->option_manager_->set_option_integer("group_anonymous_bot_user_id", get_anonymous_bot_user_id().get());
|
||||
td_->option_manager_->set_option_integer("channel_bot_user_id", get_channel_bot_user_id().get());
|
||||
if (!td_->option_manager_->have_option("anti_spam_bot_user_id")) {
|
||||
td_->option_manager_->set_option_integer("anti_spam_bot_user_id", get_anti_spam_bot_user_id().get());
|
||||
}
|
||||
|
||||
if (G()->parameters().use_chat_info_db) {
|
||||
auto next_contacts_sync_date_string = G()->td_db()->get_binlog_pmc()->get("next_contacts_sync_date");
|
||||
@ -3731,6 +3734,8 @@ ContactsManager::ContactsManager(Td *td, ActorShared<> parent) : td_(td), parent
|
||||
G()->td_db()->get_sqlite_pmc()->erase_by_prefix("us_bot_info", Auto());
|
||||
}
|
||||
|
||||
on_update_fragment_prefixes();
|
||||
|
||||
was_online_local_ = to_integer<int32>(G()->td_db()->get_binlog_pmc()->get("my_was_online_local"));
|
||||
was_online_remote_ = to_integer<int32>(G()->td_db()->get_binlog_pmc()->get("my_was_online_remote"));
|
||||
if (was_online_local_ >= G()->unix_time_cached() && !td_->is_online()) {
|
||||
@ -3791,8 +3796,6 @@ void ContactsManager::start_up() {
|
||||
if (!pending_location_visibility_expire_date_) {
|
||||
try_send_set_location_visibility_query();
|
||||
}
|
||||
|
||||
on_update_fragment_prefixes();
|
||||
}
|
||||
|
||||
void ContactsManager::tear_down() {
|
||||
@ -5664,6 +5667,10 @@ UserId ContactsManager::get_channel_bot_user_id() {
|
||||
return UserId(static_cast<int64>(G()->is_test_dc() ? 936174 : 136817688));
|
||||
}
|
||||
|
||||
UserId ContactsManager::get_anti_spam_bot_user_id() {
|
||||
return UserId(static_cast<int64>(G()->is_test_dc() ? 2200583762ll : 5434988373ll));
|
||||
}
|
||||
|
||||
UserId ContactsManager::add_anonymous_bot_user() {
|
||||
auto user_id = get_anonymous_bot_user_id();
|
||||
if (!have_user_force(user_id)) {
|
||||
@ -9774,7 +9781,8 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) {
|
||||
auto u = get_user_force_impl(user_id);
|
||||
if ((u == nullptr || !u->is_received) &&
|
||||
(user_id == get_service_notifications_user_id() || user_id == get_replies_bot_user_id() ||
|
||||
user_id == get_anonymous_bot_user_id() || user_id == get_channel_bot_user_id())) {
|
||||
user_id == get_anonymous_bot_user_id() || user_id == get_channel_bot_user_id() ||
|
||||
user_id == get_anti_spam_bot_user_id())) {
|
||||
int32 flags = USER_FLAG_HAS_ACCESS_HASH | USER_FLAG_HAS_FIRST_NAME | USER_FLAG_NEED_APPLY_MIN_PHOTO;
|
||||
int64 profile_photo_id = 0;
|
||||
int32 profile_photo_dc_id = 1;
|
||||
@ -9819,6 +9827,17 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) {
|
||||
username = G()->is_test_dc() ? "channelsbot" : "Channel_Bot";
|
||||
bot_info_version = G()->is_test_dc() ? 1 : 4;
|
||||
profile_photo_id = 587627495930570665;
|
||||
} else if (user_id == get_service_notifications_user_id()) {
|
||||
flags |= USER_FLAG_HAS_USERNAME | USER_FLAG_IS_BOT;
|
||||
if (G()->is_test_dc()) {
|
||||
first_name = "antispambot";
|
||||
username = "tantispambot";
|
||||
} else {
|
||||
flags |= USER_FLAG_IS_VERIFIED;
|
||||
first_name = "Telegram Anti-Spam";
|
||||
username = "tgsantispambot";
|
||||
profile_photo_id = 5170408289966598902;
|
||||
}
|
||||
}
|
||||
|
||||
telegram_api::object_ptr<telegram_api::userProfilePhoto> profile_photo;
|
||||
@ -9837,6 +9856,8 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) {
|
||||
on_get_user(std::move(user), "get_user_force");
|
||||
u = get_user(user_id);
|
||||
CHECK(u != nullptr && u->is_received);
|
||||
|
||||
reload_user(user_id, Promise<Unit>());
|
||||
}
|
||||
return u;
|
||||
}
|
||||
@ -15409,7 +15430,8 @@ bool ContactsManager::get_user(UserId user_id, int left_tries, Promise<Unit> &&p
|
||||
}
|
||||
|
||||
if (user_id == get_service_notifications_user_id() || user_id == get_replies_bot_user_id() ||
|
||||
user_id == get_anonymous_bot_user_id() || user_id == get_channel_bot_user_id()) {
|
||||
user_id == get_anonymous_bot_user_id() || user_id == get_channel_bot_user_id() ||
|
||||
user_id == get_anti_spam_bot_user_id()) {
|
||||
get_user_force(user_id);
|
||||
}
|
||||
|
||||
|
@ -286,6 +286,8 @@ class ContactsManager final : public Actor {
|
||||
|
||||
static UserId get_channel_bot_user_id();
|
||||
|
||||
static UserId get_anti_spam_bot_user_id();
|
||||
|
||||
UserId add_anonymous_bot_user();
|
||||
|
||||
UserId add_channel_bot_user();
|
||||
|
@ -460,7 +460,7 @@ class GetChannelAdminLogQuery final : public Td::ResultHandler {
|
||||
td_->contacts_manager_->on_get_users(std::move(events->users_), "on_get_event_log");
|
||||
td_->contacts_manager_->on_get_chats(std::move(events->chats_), "on_get_event_log");
|
||||
|
||||
auto anti_spam_user_id = UserId(G()->get_option_integer("telegram_antispam_user_id"));
|
||||
auto anti_spam_user_id = UserId(G()->get_option_integer("anti_spam_bot_user_id"));
|
||||
auto result = td_api::make_object<td_api::chatEvents>();
|
||||
result->events_.reserve(events->events_.size());
|
||||
for (auto &event : events->events_) {
|
||||
|
@ -287,8 +287,6 @@ bool OptionManager::is_internal_option(Slice name) {
|
||||
name == "saved_gifs_limit_premium" || name == "session_count" || name == "stickers_faved_limit_default" ||
|
||||
name == "stickers_faved_limit_premium" || name == "stickers_normal_by_emoji_per_premium_num" ||
|
||||
name == "stickers_premium_by_emoji_num";
|
||||
case 't':
|
||||
return name == "telegram_antispam_user_id";
|
||||
case 'v':
|
||||
return name == "video_note_size_max";
|
||||
case 'w':
|
||||
|
Loading…
Reference in New Issue
Block a user