Use new config constants.
GitOrigin-RevId: 6f0d02a9ca91e7db2d416eb89861080ff9f6f30c
This commit is contained in:
parent
a3717481ed
commit
c1e3f2d65d
@ -679,6 +679,12 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
|
||||
}
|
||||
}
|
||||
|
||||
shared_config.set_option_integer("edit_time_limit", config->edit_time_limit_);
|
||||
shared_config.set_option_boolean("revoke_pm_inbox",
|
||||
(config->flags_ & telegram_api::config::REVOKE_PM_INBOX_MASK) != 0);
|
||||
shared_config.set_option_integer("revoke_time_limit", config->revoke_time_limit_);
|
||||
shared_config.set_option_integer("revoke_pm_time_limit", config->revoke_pm_time_limit_);
|
||||
|
||||
shared_config.set_option_integer("rating_e_decay", config->rating_e_decay_);
|
||||
|
||||
if (is_from_main_dc) {
|
||||
|
@ -7411,8 +7411,13 @@ bool MessagesManager::can_revoke_message(DialogId dialog_id, const Message *m) c
|
||||
CHECK(m->message_id.is_server());
|
||||
|
||||
bool is_appointed_administrator = false;
|
||||
bool can_revoke_incoming = false;
|
||||
const int32 DEFAULT_REVOKE_TIME_LIMIT = 2 * 86400;
|
||||
int32 revoke_time_limit = G()->shared_config().get_option_integer("revoke_time_limit", DEFAULT_REVOKE_TIME_LIMIT);
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
can_revoke_incoming = G()->shared_config().get_option_boolean("revoke_pm_inbox");
|
||||
revoke_time_limit = G()->shared_config().get_option_integer("revoke_pm_time_limit", DEFAULT_REVOKE_TIME_LIMIT);
|
||||
break;
|
||||
case DialogType::Chat:
|
||||
is_appointed_administrator = td_->contacts_manager_->is_appointed_chat_administrator(dialog_id.get_chat_id());
|
||||
@ -7428,9 +7433,9 @@ bool MessagesManager::can_revoke_message(DialogId dialog_id, const Message *m) c
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO use const from the config
|
||||
return ((m->is_outgoing && !is_service_message_content(m->content->get_id())) || is_appointed_administrator) &&
|
||||
G()->unix_time_cached() < m->date + 2 * 86400;
|
||||
return (((m->is_outgoing || can_revoke_incoming) && !is_service_message_content(m->content->get_id())) ||
|
||||
is_appointed_administrator) &&
|
||||
G()->unix_time_cached() - m->date <= revoke_time_limit;
|
||||
}
|
||||
|
||||
void MessagesManager::delete_messages(DialogId dialog_id, const vector<MessageId> &input_message_ids, bool revoke,
|
||||
@ -16583,8 +16588,9 @@ bool MessagesManager::can_edit_message(DialogId dialog_id, const Message *m, boo
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO use const from the config
|
||||
if (has_edit_time_limit && G()->unix_time_cached() - m->date >= 2 * 86400 + (is_editing ? 300 : 0)) {
|
||||
const int32 DEFAULT_EDIT_TIME_LIMIT = 2 * 86400;
|
||||
int32 edit_time_limit = G()->shared_config().get_option_integer("edit_time_limit", DEFAULT_EDIT_TIME_LIMIT);
|
||||
if (has_edit_time_limit && G()->unix_time_cached() - m->date >= edit_time_limit + (is_editing ? 300 : 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3897,6 +3897,13 @@ void Td::on_result(NetQueryPtr query) {
|
||||
handler->on_result(std::move(query));
|
||||
}
|
||||
|
||||
bool Td::is_internal_config_option(Slice name) {
|
||||
return name == "call_ring_timeout_ms" || name == "call_receive_timeout_ms" || name == "channels_read_media_period" ||
|
||||
name == "edit_time_limit" || name == "revoke_pm_inbox" || name == "revoke_time_limit" ||
|
||||
name == "revoke_pm_time_limit" || name == "rating_e_decay" || name == "saved_animations_limit" ||
|
||||
name == "auth";
|
||||
}
|
||||
|
||||
void Td::on_config_option_updated(const string &name) {
|
||||
if (close_flag_) {
|
||||
return;
|
||||
@ -3918,8 +3925,7 @@ void Td::on_config_option_updated(const string &name) {
|
||||
send_closure(storage_manager_, &StorageManager::update_use_storage_optimizer);
|
||||
} else if (name == "rating_e_decay") {
|
||||
return send_closure(top_dialog_manager_, &TopDialogManager::update_rating_e_decay);
|
||||
} else if (name == "call_ring_timeout_ms" || name == "call_receive_timeout_ms" ||
|
||||
name == "channels_read_media_period") {
|
||||
} else if (is_internal_config_option(name)) {
|
||||
return;
|
||||
}
|
||||
send_closure(actor_id(this), &Td::send_update,
|
||||
@ -4112,12 +4118,9 @@ void Td::clear() {
|
||||
Timer timer;
|
||||
if (destroy_flag_) {
|
||||
for (auto &option : G()->shared_config().get_options()) {
|
||||
if (option.first == "rating_e_decay" || option.first == "saved_animations_limit" ||
|
||||
option.first == "call_receive_timeout_ms" || option.first == "call_ring_timeout_ms" ||
|
||||
option.first == "channels_read_media_period" || option.first == "auth") {
|
||||
continue;
|
||||
if (!is_internal_config_option(option.first)) {
|
||||
send_update(make_tl_object<td_api::updateOption>(option.first, make_tl_object<td_api::optionValueEmpty>()));
|
||||
}
|
||||
send_update(make_tl_object<td_api::updateOption>(option.first, make_tl_object<td_api::optionValueEmpty>()));
|
||||
}
|
||||
}
|
||||
LOG(DEBUG) << "Options was cleared " << timer;
|
||||
|
@ -255,6 +255,8 @@ class Td final : public NetQueryCallback {
|
||||
void clear_handlers();
|
||||
// void destroy_handler(ResultHandler *handler);
|
||||
|
||||
static bool is_internal_config_option(Slice name);
|
||||
|
||||
void on_config_option_updated(const string &name);
|
||||
|
||||
static tl_object_ptr<td_api::ConnectionState> get_connection_state_object(StateManager::State state);
|
||||
|
Reference in New Issue
Block a user