Support notification related options.
GitOrigin-RevId: f6e5574fe1466f779995fb3e2914fa48ba844ffe
This commit is contained in:
parent
bd8295c464
commit
c53eaf92a7
@ -854,8 +854,13 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
|
||||
shared_config.set_option_string("photo_search_bot_username", config->img_search_username_);
|
||||
}
|
||||
|
||||
shared_config.set_option_integer("online_update_period_ms", config->online_update_period_ms_);
|
||||
shared_config.set_option_integer("online_cloud_timeout_ms", config->online_cloud_timeout_ms_);
|
||||
auto fix_timeout_ms = [](int32 timeout_ms) { return clamp(timeout_ms, 1000, 86400 * 1000); };
|
||||
|
||||
shared_config.set_option_integer("online_update_period_ms", fix_timeout_ms(config->online_update_period_ms_));
|
||||
|
||||
shared_config.set_option_integer("online_cloud_timeout_ms", fix_timeout_ms(config->online_cloud_timeout_ms_));
|
||||
shared_config.set_option_integer("notification_cloud_delay_ms", fix_timeout_ms(config->notify_cloud_delay_ms_));
|
||||
shared_config.set_option_integer("notification_default_delay_ms", fix_timeout_ms(config->notify_default_delay_ms_));
|
||||
|
||||
// delete outdated options
|
||||
shared_config.set_option_empty("suggested_language_code");
|
||||
@ -884,9 +889,6 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
|
||||
// shared_config.set_option_integer("offline_blur_timeout_ms", config->offline_blur_timeout_ms_);
|
||||
// shared_config.set_option_integer("offline_idle_timeout_ms", config->offline_idle_timeout_ms_);
|
||||
|
||||
// shared_config.set_option_integer("notify_cloud_delay_ms", config->notify_cloud_delay_ms_);
|
||||
// shared_config.set_option_integer("notify_default_delay_ms", config->notify_default_delay_ms_);
|
||||
|
||||
// shared_config.set_option_integer("push_chat_period_ms", config->push_chat_period_ms_);
|
||||
// shared_config.set_option_integer("push_chat_limit", config->push_chat_limit_);
|
||||
}
|
||||
|
@ -53,12 +53,9 @@ void NotificationManager::start_up() {
|
||||
on_notification_group_count_max_changed();
|
||||
on_notification_group_size_max_changed();
|
||||
|
||||
online_cloud_timeout_ms_ =
|
||||
G()->shared_config().get_option_integer("online_cloud_timeout_ms", DEFAULT_ONLINE_CLOUD_TIMEOUT_MS);
|
||||
notification_cloud_delay_ms_ =
|
||||
G()->shared_config().get_option_integer("notification_cloud_delay_ms", DEFAULT_ONLINE_CLOUD_DELAY_MS);
|
||||
notification_default_delay_ms_ =
|
||||
G()->shared_config().get_option_integer("notification_default_delay_ms", DEFAULT_DEFAULT_DELAY_MS);
|
||||
on_online_cloud_timeout_changed();
|
||||
on_notification_cloud_delay_changed();
|
||||
on_notification_default_delay_changed();
|
||||
|
||||
// TODO load groups
|
||||
}
|
||||
@ -428,6 +425,9 @@ void NotificationManager::on_notification_group_count_max_changed() {
|
||||
return;
|
||||
}
|
||||
|
||||
VLOG(notifications) << "Change max notification group count from " << max_notification_group_count_ << " to "
|
||||
<< new_max_notification_group_count;
|
||||
|
||||
if (max_notification_group_count_ != 0) {
|
||||
// TODO
|
||||
}
|
||||
@ -449,6 +449,9 @@ void NotificationManager::on_notification_group_size_max_changed() {
|
||||
return;
|
||||
}
|
||||
|
||||
VLOG(notifications) << "Change max notification group size from " << max_notification_group_size_ << " to "
|
||||
<< new_max_notification_group_size;
|
||||
|
||||
if (max_notification_group_size_ != 0) {
|
||||
// TODO
|
||||
}
|
||||
@ -458,4 +461,22 @@ void NotificationManager::on_notification_group_size_max_changed() {
|
||||
max_notification_group_size_ + max(EXTRA_GROUP_SIZE / 2, min(max_notification_group_size_, EXTRA_GROUP_SIZE));
|
||||
}
|
||||
|
||||
void NotificationManager::on_online_cloud_timeout_changed() {
|
||||
online_cloud_timeout_ms_ =
|
||||
G()->shared_config().get_option_integer("online_cloud_timeout_ms", DEFAULT_ONLINE_CLOUD_TIMEOUT_MS);
|
||||
VLOG(notifications) << "Set online_cloud_timeout_ms to " << online_cloud_timeout_ms_;
|
||||
}
|
||||
|
||||
void NotificationManager::on_notification_cloud_delay_changed() {
|
||||
notification_cloud_delay_ms_ =
|
||||
G()->shared_config().get_option_integer("notification_cloud_delay_ms", DEFAULT_ONLINE_CLOUD_DELAY_MS);
|
||||
VLOG(notifications) << "Set notification_cloud_delay_ms to " << notification_cloud_delay_ms_;
|
||||
}
|
||||
|
||||
void NotificationManager::on_notification_default_delay_changed() {
|
||||
notification_default_delay_ms_ =
|
||||
G()->shared_config().get_option_integer("notification_default_delay_ms", DEFAULT_DEFAULT_DELAY_MS);
|
||||
VLOG(notifications) << "Set notification_default_delay_ms to " << notification_default_delay_ms_;
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -57,6 +57,12 @@ class NotificationManager : public Actor {
|
||||
|
||||
void on_notification_group_size_max_changed();
|
||||
|
||||
void on_online_cloud_timeout_changed();
|
||||
|
||||
void on_notification_cloud_delay_changed();
|
||||
|
||||
void on_notification_default_delay_changed();
|
||||
|
||||
private:
|
||||
static constexpr int32 DEFAULT_GROUP_COUNT_MAX = 10;
|
||||
static constexpr int32 DEFAULT_GROUP_SIZE_MAX = 10;
|
||||
|
@ -3426,6 +3426,8 @@ bool Td::is_internal_config_option(Slice name) {
|
||||
return name == "language_pack_version";
|
||||
case 'm':
|
||||
return name == "my_phone_number";
|
||||
case 'n':
|
||||
return name == "notification_cloud_delay_ms" || name == "notification_default_delay_ms";
|
||||
case 'o':
|
||||
return name == "online_update_period_ms" || name == "online_cloud_timeout_ms";
|
||||
case 'r':
|
||||
@ -3489,6 +3491,12 @@ void Td::on_config_option_updated(const string &name) {
|
||||
send_closure(notification_manager_actor_, &NotificationManager::on_notification_group_count_max_changed);
|
||||
} else if (name == "notification_group_size_max") {
|
||||
send_closure(notification_manager_actor_, &NotificationManager::on_notification_group_size_max_changed);
|
||||
} else if (name == "online_cloud_timeout_ms") {
|
||||
return send_closure(notification_manager_actor_, &NotificationManager::on_online_cloud_timeout_changed);
|
||||
} else if (name == "notification_cloud_delay_ms") {
|
||||
return send_closure(notification_manager_actor_, &NotificationManager::on_notification_cloud_delay_changed);
|
||||
} else if (name == "notification_default_delay_ms") {
|
||||
return send_closure(notification_manager_actor_, &NotificationManager::on_notification_default_delay_changed);
|
||||
} else if (is_internal_config_option(name)) {
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user