Disable notification API by default.
GitOrigin-RevId: 2957f2d9e83073aa9d6ba01b95f6afb692b9b4b9
This commit is contained in:
parent
7627dc27a7
commit
eb18842279
@ -21820,7 +21820,8 @@ void MessagesManager::force_create_dialog(DialogId dialog_id, const char *source
|
|||||||
update_dialog_notification_settings(dialog_id, &d->notification_settings, user_d->notification_settings);
|
update_dialog_notification_settings(dialog_id, &d->notification_settings, user_d->notification_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G()->parameters().use_message_db && !td_->contacts_manager_->get_secret_chat_is_outbound(secret_chat_id)) {
|
if (G()->parameters().use_message_db && !td_->auth_manager_->is_bot() &&
|
||||||
|
!td_->contacts_manager_->get_secret_chat_is_outbound(secret_chat_id)) {
|
||||||
d->new_secret_chat_notification_id = get_next_notification_id(d, MessageId());
|
d->new_secret_chat_notification_id = get_next_notification_id(d, MessageId());
|
||||||
auto date = td_->contacts_manager_->get_secret_chat_date(secret_chat_id);
|
auto date = td_->contacts_manager_->get_secret_chat_date(secret_chat_id);
|
||||||
bool is_changed =
|
bool is_changed =
|
||||||
|
@ -112,25 +112,27 @@ void NotificationManager::start_up() {
|
|||||||
current_notification_group_id_ =
|
current_notification_group_id_ =
|
||||||
NotificationGroupId(to_integer<int32>(G()->td_db()->get_binlog_pmc()->get("notification_group_id_current")));
|
NotificationGroupId(to_integer<int32>(G()->td_db()->get_binlog_pmc()->get("notification_group_id_current")));
|
||||||
|
|
||||||
on_notification_group_count_max_changed();
|
on_notification_group_count_max_changed(false);
|
||||||
on_notification_group_size_max_changed();
|
on_notification_group_size_max_changed();
|
||||||
|
|
||||||
on_online_cloud_timeout_changed();
|
on_online_cloud_timeout_changed();
|
||||||
on_notification_cloud_delay_changed();
|
on_notification_cloud_delay_changed();
|
||||||
on_notification_default_delay_changed();
|
on_notification_default_delay_changed();
|
||||||
|
|
||||||
last_loaded_notification_group_key_.last_notification_date = std::numeric_limits<int32>::max();
|
if (max_notification_group_count_ != 0) {
|
||||||
|
last_loaded_notification_group_key_.last_notification_date = std::numeric_limits<int32>::max();
|
||||||
|
|
||||||
int32 loaded_groups = 0;
|
int32 loaded_groups = 0;
|
||||||
int32 needed_groups = static_cast<int32>(max_notification_group_count_);
|
int32 needed_groups = static_cast<int32>(max_notification_group_count_);
|
||||||
do {
|
do {
|
||||||
loaded_groups += load_message_notification_groups_from_database(needed_groups, false);
|
loaded_groups += load_message_notification_groups_from_database(needed_groups, false);
|
||||||
} while (loaded_groups < needed_groups && last_loaded_notification_group_key_.last_notification_date != 0);
|
} while (loaded_groups < needed_groups && last_loaded_notification_group_key_.last_notification_date != 0);
|
||||||
|
|
||||||
auto update = get_update_active_notificaitons();
|
auto update = get_update_active_notificaitons();
|
||||||
if (update != nullptr) {
|
if (update != nullptr) {
|
||||||
VLOG(notifications) << "Send " << as_active_notifications_update(update.get());
|
VLOG(notifications) << "Send " << as_active_notifications_update(update.get());
|
||||||
send_closure(G()->td(), &Td::send_update, std::move(update));
|
send_closure(G()->td(), &Td::send_update, std::move(update));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,6 +184,10 @@ NotificationManager::NotificationGroups::iterator NotificationManager::get_group
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::load_group_force(NotificationGroupId group_id) {
|
void NotificationManager::load_group_force(NotificationGroupId group_id) {
|
||||||
|
if (is_disabled() || max_notification_group_count_ == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto group_it = get_group_force(group_id, true);
|
auto group_it = get_group_force(group_id, true);
|
||||||
CHECK(group_it != groups_.end());
|
CHECK(group_it != groups_.end());
|
||||||
}
|
}
|
||||||
@ -558,7 +564,7 @@ int32 NotificationManager::get_notification_delay_ms(DialogId dialog_id,
|
|||||||
void NotificationManager::add_notification(NotificationGroupId group_id, DialogId dialog_id, int32 date,
|
void NotificationManager::add_notification(NotificationGroupId group_id, DialogId dialog_id, int32 date,
|
||||||
DialogId notification_settings_dialog_id, bool is_silent,
|
DialogId notification_settings_dialog_id, bool is_silent,
|
||||||
NotificationId notification_id, unique_ptr<NotificationType> type) {
|
NotificationId notification_id, unique_ptr<NotificationType> type) {
|
||||||
if (is_disabled()) {
|
if (is_disabled() || max_notification_group_count_ == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1193,7 +1199,7 @@ void NotificationManager::flush_all_pending_notifications() {
|
|||||||
|
|
||||||
void NotificationManager::edit_notification(NotificationGroupId group_id, NotificationId notification_id,
|
void NotificationManager::edit_notification(NotificationGroupId group_id, NotificationId notification_id,
|
||||||
unique_ptr<NotificationType> type) {
|
unique_ptr<NotificationType> type) {
|
||||||
if (is_disabled()) {
|
if (is_disabled() || max_notification_group_count_ == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1346,7 +1352,7 @@ void NotificationManager::remove_notification(NotificationGroupId group_id, Noti
|
|||||||
return promise.set_error(Status::Error(400, "Notification identifier is invalid"));
|
return promise.set_error(Status::Error(400, "Notification identifier is invalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_disabled()) {
|
if (is_disabled() || max_notification_group_count_ == 0) {
|
||||||
return promise.set_value(Unit());
|
return promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1429,7 +1435,7 @@ void NotificationManager::remove_notification_group(NotificationGroupId group_id
|
|||||||
return promise.set_error(Status::Error(400, "Notification identifier is invalid"));
|
return promise.set_error(Status::Error(400, "Notification identifier is invalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_disabled()) {
|
if (is_disabled() || max_notification_group_count_ == 0) {
|
||||||
return promise.set_value(Unit());
|
return promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1525,7 +1531,7 @@ void NotificationManager::remove_notification_group(NotificationGroupId group_id
|
|||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::on_notification_group_count_max_changed() {
|
void NotificationManager::on_notification_group_count_max_changed(bool send_updates) {
|
||||||
if (is_disabled()) {
|
if (is_disabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1544,7 +1550,7 @@ void NotificationManager::on_notification_group_count_max_changed() {
|
|||||||
<< new_max_notification_group_count;
|
<< new_max_notification_group_count;
|
||||||
|
|
||||||
bool is_increased = new_max_notification_group_count_size_t > max_notification_group_count_;
|
bool is_increased = new_max_notification_group_count_size_t > max_notification_group_count_;
|
||||||
if (max_notification_group_count_ != 0) {
|
if (send_updates) {
|
||||||
flush_all_pending_notifications();
|
flush_all_pending_notifications();
|
||||||
flush_all_pending_updates(true, "on_notification_group_size_max_changed begin");
|
flush_all_pending_updates(true, "on_notification_group_size_max_changed begin");
|
||||||
|
|
||||||
@ -1569,6 +1575,14 @@ void NotificationManager::on_notification_group_count_max_changed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
flush_all_pending_updates(true, "on_notification_group_size_max_changed end");
|
flush_all_pending_updates(true, "on_notification_group_size_max_changed end");
|
||||||
|
|
||||||
|
if (new_max_notification_group_count == 0) {
|
||||||
|
last_loaded_notification_group_key_ = NotificationGroupKey();
|
||||||
|
last_loaded_notification_group_key_.last_notification_date = std::numeric_limits<int32>::max();
|
||||||
|
CHECK(pending_updates_.empty());
|
||||||
|
groups_.clear();
|
||||||
|
group_keys_.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
max_notification_group_count_ = new_max_notification_group_count_size_t;
|
max_notification_group_count_ = new_max_notification_group_count_size_t;
|
||||||
@ -1674,10 +1688,18 @@ void NotificationManager::on_notification_default_delay_changed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::before_get_difference() {
|
void NotificationManager::before_get_difference() {
|
||||||
|
if (is_disabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
running_get_difference_ = true;
|
running_get_difference_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::after_get_difference() {
|
void NotificationManager::after_get_difference() {
|
||||||
|
if (is_disabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CHECK(running_get_difference_);
|
CHECK(running_get_difference_);
|
||||||
running_get_difference_ = false;
|
running_get_difference_ = false;
|
||||||
flush_pending_notifications_timeout_.set_timeout_in(0, MIN_NOTIFICATION_DELAY_MS * 1e-3);
|
flush_pending_notifications_timeout_.set_timeout_in(0, MIN_NOTIFICATION_DELAY_MS * 1e-3);
|
||||||
@ -1693,12 +1715,20 @@ void NotificationManager::after_get_difference_impl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::before_get_chat_difference(NotificationGroupId group_id) {
|
void NotificationManager::before_get_chat_difference(NotificationGroupId group_id) {
|
||||||
|
if (is_disabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VLOG(notifications) << "Before get chat difference in " << group_id;
|
VLOG(notifications) << "Before get chat difference in " << group_id;
|
||||||
CHECK(group_id.is_valid());
|
CHECK(group_id.is_valid());
|
||||||
running_get_chat_difference_.insert(group_id.get());
|
running_get_chat_difference_.insert(group_id.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::after_get_chat_difference(NotificationGroupId group_id) {
|
void NotificationManager::after_get_chat_difference(NotificationGroupId group_id) {
|
||||||
|
if (is_disabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VLOG(notifications) << "After get chat difference in " << group_id;
|
VLOG(notifications) << "After get chat difference in " << group_id;
|
||||||
CHECK(group_id.is_valid());
|
CHECK(group_id.is_valid());
|
||||||
auto erased_count = running_get_chat_difference_.erase(group_id.get());
|
auto erased_count = running_get_chat_difference_.erase(group_id.get());
|
||||||
@ -1721,7 +1751,7 @@ void NotificationManager::after_get_chat_difference_impl(NotificationGroupId gro
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
|
void NotificationManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
|
||||||
if (is_disabled()) {
|
if (is_disabled() || max_notification_group_count_ == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class Td;
|
|||||||
|
|
||||||
class NotificationManager : public Actor {
|
class NotificationManager : public Actor {
|
||||||
public:
|
public:
|
||||||
static constexpr int32 MIN_NOTIFICATION_GROUP_COUNT_MAX = 1;
|
static constexpr int32 MIN_NOTIFICATION_GROUP_COUNT_MAX = 0;
|
||||||
static constexpr int32 MAX_NOTIFICATION_GROUP_COUNT_MAX = 25;
|
static constexpr int32 MAX_NOTIFICATION_GROUP_COUNT_MAX = 25;
|
||||||
static constexpr int32 MIN_NOTIFICATION_GROUP_SIZE_MAX = 1;
|
static constexpr int32 MIN_NOTIFICATION_GROUP_SIZE_MAX = 1;
|
||||||
static constexpr int32 MAX_NOTIFICATION_GROUP_SIZE_MAX = 25;
|
static constexpr int32 MAX_NOTIFICATION_GROUP_SIZE_MAX = 25;
|
||||||
@ -69,7 +69,7 @@ class NotificationManager : public Actor {
|
|||||||
void remove_notification_group(NotificationGroupId group_id, NotificationId max_notification_id,
|
void remove_notification_group(NotificationGroupId group_id, NotificationId max_notification_id,
|
||||||
MessageId max_message_id, int32 new_total_count, Promise<Unit> &&promise);
|
MessageId max_message_id, int32 new_total_count, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void on_notification_group_count_max_changed();
|
void on_notification_group_count_max_changed(bool send_updates);
|
||||||
|
|
||||||
void on_notification_group_size_max_changed();
|
void on_notification_group_size_max_changed();
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class NotificationManager : public Actor {
|
|||||||
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr int32 DEFAULT_GROUP_COUNT_MAX = 10;
|
static constexpr int32 DEFAULT_GROUP_COUNT_MAX = 0;
|
||||||
static constexpr int32 DEFAULT_GROUP_SIZE_MAX = 10;
|
static constexpr int32 DEFAULT_GROUP_SIZE_MAX = 10;
|
||||||
static constexpr size_t EXTRA_GROUP_SIZE = 10;
|
static constexpr size_t EXTRA_GROUP_SIZE = 10;
|
||||||
|
|
||||||
@ -192,6 +192,10 @@ class NotificationManager : public Actor {
|
|||||||
|
|
||||||
void flush_all_pending_updates(bool include_delayed_chats, const char *source);
|
void flush_all_pending_updates(bool include_delayed_chats, const char *source);
|
||||||
|
|
||||||
|
void after_get_difference_impl();
|
||||||
|
|
||||||
|
void after_get_chat_difference_impl(NotificationGroupId group_id);
|
||||||
|
|
||||||
NotificationId current_notification_id_;
|
NotificationId current_notification_id_;
|
||||||
NotificationGroupId current_notification_group_id_;
|
NotificationGroupId current_notification_group_id_;
|
||||||
|
|
||||||
@ -213,10 +217,6 @@ class NotificationManager : public Actor {
|
|||||||
|
|
||||||
std::unordered_map<int32, vector<td_api::object_ptr<td_api::Update>>> pending_updates_;
|
std::unordered_map<int32, vector<td_api::object_ptr<td_api::Update>>> pending_updates_;
|
||||||
|
|
||||||
void after_get_difference_impl();
|
|
||||||
|
|
||||||
void after_get_chat_difference_impl(NotificationGroupId group_id);
|
|
||||||
|
|
||||||
MultiTimeout flush_pending_notifications_timeout_{"FlushPendingNotificationsTimeout"};
|
MultiTimeout flush_pending_notifications_timeout_{"FlushPendingNotificationsTimeout"};
|
||||||
MultiTimeout flush_pending_updates_timeout_{"FlushPendingUpdatesTimeout"};
|
MultiTimeout flush_pending_updates_timeout_{"FlushPendingUpdatesTimeout"};
|
||||||
|
|
||||||
|
@ -3570,7 +3570,7 @@ void Td::on_config_option_updated(const string &name) {
|
|||||||
send_closure(language_pack_manager_, &LanguagePackManager::on_language_pack_version_changed, -1);
|
send_closure(language_pack_manager_, &LanguagePackManager::on_language_pack_version_changed, -1);
|
||||||
return;
|
return;
|
||||||
} else if (name == "notification_group_count_max") {
|
} else if (name == "notification_group_count_max") {
|
||||||
send_closure(notification_manager_actor_, &NotificationManager::on_notification_group_count_max_changed);
|
send_closure(notification_manager_actor_, &NotificationManager::on_notification_group_count_max_changed, true);
|
||||||
} else if (name == "notification_group_size_max") {
|
} else if (name == "notification_group_size_max") {
|
||||||
send_closure(notification_manager_actor_, &NotificationManager::on_notification_group_size_max_changed);
|
send_closure(notification_manager_actor_, &NotificationManager::on_notification_group_size_max_changed);
|
||||||
} else if (name == "online_cloud_timeout_ms") {
|
} else if (name == "online_cloud_timeout_ms") {
|
||||||
|
Loading…
Reference in New Issue
Block a user