Add source to remove_notification.

GitOrigin-RevId: 217f967c61005275e5582ae0705b3b24fc8a73c2
This commit is contained in:
levlam 2019-04-19 01:52:15 +03:00
parent d2e2aa7f7a
commit 896e44ac94
4 changed files with 33 additions and 23 deletions

View File

@ -10323,7 +10323,8 @@ void MessagesManager::set_dialog_pinned_message_notification(Dialog *d, MessageI
on_message_changed(d, m, false, "set_dialog_pinned_message_notification");
} else {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
d->mention_notification_group.group_id, old_message_id, false);
d->mention_notification_group.group_id, old_message_id, false,
"set_dialog_pinned_message_notification");
}
}
d->pinned_message_notification_message_id = message_id;
@ -10375,7 +10376,8 @@ void MessagesManager::remove_dialog_mention_notifications(Dialog *d) {
removed_notification_ids_set.end());
for (size_t i = 0; i < removed_notification_ids.size(); i++) {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification, notification_group_id,
removed_notification_ids[i], false, i + 1 == removed_notification_ids.size(), Promise<Unit>());
removed_notification_ids[i], false, i + 1 == removed_notification_ids.size(), Promise<Unit>(),
"remove_dialog_mention_notifications");
}
}
@ -10932,7 +10934,8 @@ void MessagesManager::remove_message_notification_id(Dialog *d, Message *m, bool
if (is_permanent) {
if (had_active_notification) {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification, group_info.group_id,
notification_id, is_permanent, force_update, Promise<Unit>());
notification_id, is_permanent, force_update, Promise<Unit>(),
"remove_message_notification_id");
}
// on_message_changed will be called by the caller
@ -10955,7 +10958,8 @@ void MessagesManager::remove_new_secret_chat_notification(Dialog *d, bool is_per
if (is_permanent) {
CHECK(d->message_notification_group.group_id.is_valid());
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification,
d->message_notification_group.group_id, notification_id, true, true, Promise<Unit>());
d->message_notification_group.group_id, notification_id, true, true, Promise<Unit>(),
"remove_new_secret_chat_notification");
}
}
@ -19131,10 +19135,10 @@ void MessagesManager::remove_message_notifications_by_message_ids(DialogId dialo
if (m == nullptr) {
LOG(INFO) << "Can't delete " << message_id << " because it is not found";
// call synchronously to remove them before ProcessPush returns
td_->notification_manager_->remove_temporary_notification_by_message_id(d->message_notification_group.group_id,
message_id, true);
td_->notification_manager_->remove_temporary_notification_by_message_id(d->mention_notification_group.group_id,
message_id, true);
td_->notification_manager_->remove_temporary_notification_by_message_id(
d->message_notification_group.group_id, message_id, true, "remove_message_notifications_by_message_ids");
td_->notification_manager_->remove_temporary_notification_by_message_id(
d->mention_notification_group.group_id, message_id, true, "remove_message_notifications_by_message_ids");
continue;
}
deleted_message_ids.push_back(m->message_id.get());
@ -22696,7 +22700,8 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
}
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification,
d->mention_notification_group.group_id, notification_id, false, false, Promise<Unit>());
d->mention_notification_group.group_id, notification_id, false, false, Promise<Unit>(),
"remove disabled mention notification");
on_message_changed(d, message.get(), false, "remove_mention_notification");
}
@ -23108,14 +23113,14 @@ void MessagesManager::delete_message_from_database(Dialog *d, MessageId message_
}
if (is_message_notification_active(d, m)) {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification, group_info.group_id,
m->notification_id, true, false, Promise<Unit>());
m->notification_id, true, false, Promise<Unit>(), "delete_message_from_database");
}
}
} else if (message_id.get() > d->last_new_message_id.get()) {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
d->message_notification_group.group_id, message_id, false);
d->message_notification_group.group_id, message_id, false, "delete_message_from_database");
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
d->mention_notification_group.group_id, message_id, false);
d->mention_notification_group.group_id, message_id, false, "delete_message_from_database");
}
auto need_delete_message_files = m != nullptr && (d->dialog_id.get_type() == DialogType::User ||
@ -23884,7 +23889,8 @@ void MessagesManager::fix_new_dialog(Dialog *d, unique_ptr<Message> &&last_datab
VLOG(notifications) << "Remove disabled pinned message notification in " << pinned_message_id << " in "
<< dialog_id;
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
d->mention_notification_group.group_id, pinned_message_id, true);
d->mention_notification_group.group_id, pinned_message_id, true,
"fix pinned message notification");
d->pinned_message_notification_message_id = MessageId();
on_dialog_updated(d->dialog_id, "fix pinned message notification 2");
}

View File

@ -1791,7 +1791,8 @@ void NotificationManager::remove_added_notifications_from_pending_updates(
}
void NotificationManager::remove_notification(NotificationGroupId group_id, NotificationId notification_id,
bool is_permanent, bool force_update, Promise<Unit> &&promise) {
bool is_permanent, bool force_update, Promise<Unit> &&promise,
const char *source) {
if (!group_id.is_valid()) {
return promise.set_error(Status::Error(400, "Notification group identifier is invalid"));
}
@ -1803,8 +1804,8 @@ void NotificationManager::remove_notification(NotificationGroupId group_id, Noti
return promise.set_value(Unit());
}
VLOG(notifications) << "Remove " << notification_id << " from " << group_id
<< " with force_update = " << force_update;
VLOG(notifications) << "Remove " << notification_id << " from " << group_id << " with force_update = " << force_update
<< " from " << source;
auto group_it = get_group_force(group_id);
if (group_it == groups_.end()) {
@ -1887,12 +1888,13 @@ void NotificationManager::remove_notification(NotificationGroupId group_id, Noti
}
void NotificationManager::remove_temporary_notification_by_message_id(NotificationGroupId group_id,
MessageId message_id, bool force_update) {
MessageId message_id, bool force_update,
const char *source) {
if (!group_id.is_valid()) {
return;
}
VLOG(notifications) << "Remove notification for " << message_id << " in " << group_id;
VLOG(notifications) << "Remove notification for " << message_id << " in " << group_id << " from " << source;
CHECK(message_id.is_valid());
auto group_it = get_group(group_id);
@ -1906,7 +1908,8 @@ void NotificationManager::remove_temporary_notification_by_message_id(Notificati
for (auto file_id : notification.type->get_file_ids(td_)) {
this->td_->file_manager_->delete_file(file_id, Promise<>(), "remove_temporary_notification_by_message_id");
}
return this->remove_notification(group_id, notification.notification_id, true, force_update, Auto());
return this->remove_notification(group_id, notification.notification_id, true, force_update, Auto(),
"remove_temporary_notification_by_message_id");
}
}
};
@ -2307,7 +2310,7 @@ void NotificationManager::remove_call_notification(DialogId dialog_id, CallId ca
auto &active_notifications = active_call_notifications_[dialog_id];
for (auto it = active_notifications.begin(); it != active_notifications.end(); ++it) {
if (it->call_id == call_id) {
remove_notification(group_id, it->notification_id, true, true, Promise<Unit>());
remove_notification(group_id, it->notification_id, true, true, Promise<Unit>(), "remove_call_notification");
active_notifications.erase(it);
if (active_notifications.empty()) {
VLOG(notifications) << "Reuse call " << group_id;

View File

@ -72,12 +72,12 @@ class NotificationManager : public Actor {
unique_ptr<NotificationType> type);
void remove_notification(NotificationGroupId group_id, NotificationId notification_id, bool is_permanent,
bool force_update, Promise<Unit> &&promise);
bool force_update, Promise<Unit> &&promise, const char *source);
void remove_temporary_notifications(NotificationGroupId group_id, const char *source);
void remove_temporary_notification_by_message_id(NotificationGroupId group_id, MessageId message_id,
bool force_update);
bool force_update, const char *source);
void remove_notification_group(NotificationGroupId group_id, NotificationId max_notification_id,
MessageId max_message_id, int32 new_total_count, bool force_update,

View File

@ -5296,7 +5296,8 @@ void Td::on_request(uint64 id, const td_api::removeNotification &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
notification_manager_->remove_notification(NotificationGroupId(request.notification_group_id_),
NotificationId(request.notification_id_), false, true, std::move(promise));
NotificationId(request.notification_id_), false, true, std::move(promise),
"td_api::removeNotification");
}
void Td::on_request(uint64 id, const td_api::removeNotificationGroup &request) {