Support updateActiveNotifications in getCurrentState.
GitOrigin-RevId: a0fddcbbd4c54bf338b3e84d0355849e848c7524
This commit is contained in:
parent
f435fe62a1
commit
d772ab6de0
@ -125,6 +125,15 @@ void NotificationManager::start_up() {
|
|||||||
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();
|
||||||
|
if (update != nullptr) {
|
||||||
|
VLOG(notifications) << "Send " << as_active_notifications_update(update.get());
|
||||||
|
send_closure(G()->td(), &Td::send_update, std::move(update));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::updateActiveNotifications> NotificationManager::get_update_active_notificaitons() const {
|
||||||
|
auto needed_groups = max_notification_group_count_;
|
||||||
vector<td_api::object_ptr<td_api::notificationGroup>> groups;
|
vector<td_api::object_ptr<td_api::notificationGroup>> groups;
|
||||||
for (auto &group : groups_) {
|
for (auto &group : groups_) {
|
||||||
if (needed_groups == 0 || group.first.last_notification_date == 0) {
|
if (needed_groups == 0 || group.first.last_notification_date == 0) {
|
||||||
@ -144,11 +153,11 @@ void NotificationManager::start_up() {
|
|||||||
group.first.group_id.get(), group.first.dialog_id.get(), group.second.total_count, std::move(notifications)));
|
group.first.group_id.get(), group.first.dialog_id.get(), group.second.total_count, std::move(notifications)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!groups.empty()) {
|
if (groups.empty()) {
|
||||||
auto update = td_api::make_object<td_api::updateActiveNotifications>(std::move(groups));
|
return nullptr;
|
||||||
VLOG(notifications) << "Send " << as_active_notifications_update(update.get());
|
|
||||||
send_closure(G()->td(), &Td::send_update, std::move(update));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return td_api::make_object<td_api::updateActiveNotifications>(std::move(groups));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::tear_down() {
|
void NotificationManager::tear_down() {
|
||||||
@ -1694,4 +1703,15 @@ void NotificationManager::after_get_chat_difference_impl(NotificationGroupId gro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotificationManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
|
||||||
|
if (is_disabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto update = get_update_active_notificaitons();
|
||||||
|
if (update != nullptr) {
|
||||||
|
updates.push_back(std::move(update));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -84,6 +84,8 @@ class NotificationManager : public Actor {
|
|||||||
|
|
||||||
void after_get_chat_difference(NotificationGroupId group_id);
|
void after_get_chat_difference(NotificationGroupId group_id);
|
||||||
|
|
||||||
|
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 = 10;
|
||||||
static constexpr int32 DEFAULT_GROUP_SIZE_MAX = 10;
|
static constexpr int32 DEFAULT_GROUP_SIZE_MAX = 10;
|
||||||
@ -157,6 +159,8 @@ class NotificationManager : public Actor {
|
|||||||
|
|
||||||
NotificationGroupKey get_last_updated_group_key() const;
|
NotificationGroupKey get_last_updated_group_key() const;
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::updateActiveNotifications> get_update_active_notificaitons() const;
|
||||||
|
|
||||||
void send_remove_group_update(const NotificationGroupKey &group_key, const NotificationGroup &group,
|
void send_remove_group_update(const NotificationGroupKey &group_key, const NotificationGroup &group,
|
||||||
vector<int32> &&removed_notification_ids);
|
vector<int32> &&removed_notification_ids);
|
||||||
|
|
||||||
|
@ -4532,6 +4532,8 @@ void Td::on_request(uint64 id, const td_api::getCurrentState &request) {
|
|||||||
|
|
||||||
messages_manager_->get_current_state(updates);
|
messages_manager_->get_current_state(updates);
|
||||||
|
|
||||||
|
notification_manager_->get_current_state(updates);
|
||||||
|
|
||||||
// TODO updateFileGenerationStart generation_id:int64 original_path:string destination_path:string conversion:string = Update;
|
// TODO updateFileGenerationStart generation_id:int64 original_path:string destination_path:string conversion:string = Update;
|
||||||
// TODO updateCall call:call = Update;
|
// TODO updateCall call:call = Update;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user