Add NotificationGroupType.
GitOrigin-RevId: 328adc5df3cbe278008c11d5a35da93da88b7d41
This commit is contained in:
parent
2740e57c9c
commit
a05c43ceeb
@ -540,6 +540,7 @@ set(TDLIB_SOURCE
|
||||
td/telegram/Notification.h
|
||||
td/telegram/NotificationGroupId.h
|
||||
td/telegram/NotificationGroupKey.h
|
||||
td/telegram/NotificationGroupType.h
|
||||
td/telegram/NotificationId.h
|
||||
td/telegram/NotificationManager.h
|
||||
td/telegram/NotificationSettings.h
|
||||
|
@ -1355,7 +1355,7 @@ searchMessagesFilterVoiceAndVideoNote = SearchMessagesFilter;
|
||||
//@description Returns only messages with mentions of the current user, or messages that are replies to their messages
|
||||
searchMessagesFilterMention = SearchMessagesFilter;
|
||||
|
||||
//@description Returns only messages with unread mentions of the current user or messages that are replies to their messages. When using this filter the results can't be additionally filtered by a query or by the sending user
|
||||
//@description Returns only messages with unread mentions of the current user, or messages that are replies to their messages. When using this filter the results can't be additionally filtered by a query or by the sending user
|
||||
searchMessagesFilterUnreadMention = SearchMessagesFilter;
|
||||
|
||||
|
||||
@ -1815,12 +1815,28 @@ notificationTypeNewSecretChat = NotificationType;
|
||||
notificationTypeNewCall call_id:int32 = NotificationType;
|
||||
|
||||
|
||||
//@class NotificationGroupType @description Describes type of notifications in the group
|
||||
|
||||
//@description A group containing notifications of type notificationTypeNewMessage with ordinary unread messages
|
||||
notificationGroupTypeMessages = NotificationGroupType;
|
||||
|
||||
//@description A group containing notifications of type notificationTypeNewMessage with unread mentions of the current user, replies to their messages, or a pinned message
|
||||
notificationGroupTypeMentions = NotificationGroupType;
|
||||
|
||||
//@description A group containing a notification of type notificationTypeSecretChat
|
||||
notificationGroupTypeSecretChat = NotificationGroupType;
|
||||
|
||||
//@description A group containing notifications of type notificationTypeNewCall
|
||||
notificationGroupTypeCalls = NotificationGroupType;
|
||||
|
||||
|
||||
//@description Contains information about a notification @id Unique persistent identifier of this notification @date Notification date @type Notification type
|
||||
notification id:int32 date:int32 type:NotificationType = Notification;
|
||||
|
||||
//@description Describes a group of notifications @id Unique persistent auto-incremented from 1 identifier of the notification group @chat_id Identifier of a chat to which all notifications in the group belong
|
||||
//@description Describes a group of notifications @id Unique persistent auto-incremented from 1 identifier of the notification group @type Type of the group
|
||||
//@chat_id Identifier of a chat to which all notifications in the group belong
|
||||
//@total_count Total number of active notifications in the group @notifications The list of active notifications
|
||||
notificationGroup id:int32 chat_id:int53 total_count:int32 notifications:vector<notification> = NotificationGroup;
|
||||
notificationGroup id:int32 type:NotificationGroupType chat_id:int53 total_count:int32 notifications:vector<notification> = NotificationGroup;
|
||||
|
||||
|
||||
//@class OptionValue @description Represents the value of an option
|
||||
@ -2246,10 +2262,11 @@ updateChatDraftMessage chat_id:int53 draft_message:draftMessage order:int64 = Up
|
||||
//@description A notification was changed @notification_group_id Unique notification group identifier @notification Changed notification
|
||||
updateNotification notification_group_id:int32 notification:notification = Update;
|
||||
|
||||
//@description A list of active notifications in a notification group has changed @notification_group_id Unique notification group identifier @chat_id Identifier of a chat to which all notifications in the group belong
|
||||
//@description A list of active notifications in a notification group has changed @notification_group_id Unique notification group identifier @type New type of the notification group
|
||||
//@chat_id Identifier of a chat to which all notifications in the group belong
|
||||
//@notification_settings_chat_id Chat identifier, which notification settings must be applied @is_silent True, if the notifications should be shown without sound
|
||||
//@total_count Total number of active notifications in the group @added_notifications List of added group notifications @removed_notification_ids Identifiers of removed group notifications
|
||||
updateNotificationGroup notification_group_id:int32 chat_id:int53 notification_settings_chat_id:int53 is_silent:Bool total_count:int32 added_notifications:vector<notification> removed_notification_ids:vector<int32> = Update;
|
||||
updateNotificationGroup notification_group_id:int32 type:NotificationGroupType chat_id:int53 notification_settings_chat_id:int53 is_silent:Bool total_count:int32 added_notifications:vector<notification> removed_notification_ids:vector<int32> = Update;
|
||||
|
||||
//@description Contains active notifications that was shown on previous application launches. This update is sent only if a message database is used. In that case it comes once before any updateNotification and updateNotificationGroup update @groups Lists of active notification groups
|
||||
updateActiveNotifications groups:vector<notificationGroup> = Update;
|
||||
|
Binary file not shown.
@ -28,6 +28,7 @@
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/net/NetActor.h"
|
||||
#include "td/telegram/net/NetQuery.h"
|
||||
#include "td/telegram/NotificationGroupType.h"
|
||||
#include "td/telegram/NotificationManager.h"
|
||||
#include "td/telegram/NotificationSettings.hpp"
|
||||
#include "td/telegram/NotificationType.h"
|
||||
@ -17639,6 +17640,7 @@ MessagesManager::MessageNotificationGroup MessagesManager::get_message_notificat
|
||||
MessageNotificationGroup result;
|
||||
VLOG(notifications) << "Found " << d->dialog_id << " by " << group_id;
|
||||
result.dialog_id = d->dialog_id;
|
||||
result.type = from_mentions ? NotificationGroupType::Mentions : NotificationGroupType::Messages;
|
||||
result.total_count = get_dialog_pending_notification_count(d, from_mentions);
|
||||
result.total_count -= static_cast<int32>(from_mentions ? d->pending_new_mention_notifications.size()
|
||||
: d->pending_new_message_notifications.size());
|
||||
@ -18142,7 +18144,8 @@ bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool f
|
||||
CHECK(is_changed);
|
||||
VLOG(notifications) << "Create " << m->notification_id << " with " << m->message_id << " in " << d->dialog_id;
|
||||
send_closure_later(G()->notification_manager(), &NotificationManager::add_notification, notification_group_id,
|
||||
d->dialog_id, m->date, settings_dialog_id, m->disable_notification, m->notification_id,
|
||||
from_mentions ? NotificationGroupType::Mentions : NotificationGroupType::Messages, d->dialog_id,
|
||||
m->date, settings_dialog_id, m->disable_notification, m->notification_id,
|
||||
create_new_message_notification(m->message_id));
|
||||
return true;
|
||||
}
|
||||
@ -21858,8 +21861,8 @@ void MessagesManager::force_create_dialog(DialogId dialog_id, const char *source
|
||||
CHECK(is_changed);
|
||||
VLOG(notifications) << "Create " << d->new_secret_chat_notification_id << " with " << secret_chat_id;
|
||||
send_closure_later(G()->notification_manager(), &NotificationManager::add_notification, notification_group_id,
|
||||
dialog_id, date, dialog_id, false, d->new_secret_chat_notification_id,
|
||||
create_new_secret_chat_notification());
|
||||
NotificationGroupType::SecretChat, dialog_id, date, dialog_id, false,
|
||||
d->new_secret_chat_notification_id, create_new_secret_chat_notification());
|
||||
}
|
||||
}
|
||||
if (!have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "td/telegram/Notification.h"
|
||||
#include "td/telegram/NotificationGroupId.h"
|
||||
#include "td/telegram/NotificationGroupKey.h"
|
||||
#include "td/telegram/NotificationGroupType.h"
|
||||
#include "td/telegram/NotificationId.h"
|
||||
#include "td/telegram/NotificationSettings.h"
|
||||
#include "td/telegram/ReplyMarkup.h"
|
||||
@ -655,6 +656,7 @@ class MessagesManager : public Actor {
|
||||
|
||||
struct MessageNotificationGroup {
|
||||
DialogId dialog_id;
|
||||
NotificationGroupType type = NotificationGroupType::Calls;
|
||||
int32 total_count = 0;
|
||||
vector<Notification> notifications;
|
||||
};
|
||||
|
67
td/telegram/NotificationGroupType.h
Normal file
67
td/telegram/NotificationGroupType.h
Normal file
@ -0,0 +1,67 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/td_api.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
enum class NotificationGroupType : int8 { Messages, Mentions, SecretChat, Calls };
|
||||
|
||||
inline td_api::object_ptr<td_api::NotificationGroupType> get_notification_group_type_object(NotificationGroupType type) {
|
||||
switch (type) {
|
||||
case NotificationGroupType::Messages:
|
||||
return td_api::make_object<td_api::notificationGroupTypeMessages>();
|
||||
case NotificationGroupType::Mentions:
|
||||
return td_api::make_object<td_api::notificationGroupTypeMentions>();
|
||||
case NotificationGroupType::SecretChat:
|
||||
return td_api::make_object<td_api::notificationGroupTypeSecretChat>();
|
||||
case NotificationGroupType::Calls:
|
||||
return td_api::make_object<td_api::notificationGroupTypeCalls>();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
inline NotificationGroupType get_notification_group_type(const td_api::object_ptr<td_api::NotificationGroupType> &type) {
|
||||
CHECK(type != nullptr);
|
||||
switch (type->get_id()) {
|
||||
case td_api::notificationGroupTypeMessages::ID:
|
||||
return NotificationGroupType::Messages;
|
||||
case td_api::notificationGroupTypeMentions::ID:
|
||||
return NotificationGroupType::Mentions;
|
||||
case td_api::notificationGroupTypeSecretChat::ID:
|
||||
return NotificationGroupType::SecretChat;
|
||||
case td_api::notificationGroupTypeCalls::ID:
|
||||
return NotificationGroupType::Calls;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return NotificationGroupType::Calls;
|
||||
}
|
||||
}
|
||||
|
||||
inline StringBuilder &operator<<(StringBuilder &sb, const NotificationGroupType &type) {
|
||||
switch (type) {
|
||||
case NotificationGroupType::Messages:
|
||||
return sb << "Messages";
|
||||
case NotificationGroupType::Mentions:
|
||||
return sb << "Mentions";
|
||||
case NotificationGroupType::SecretChat:
|
||||
return sb << "SecretChat";
|
||||
case NotificationGroupType::Calls:
|
||||
return sb << "Calls";
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return sb;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
@ -91,7 +91,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const ActiveNotificatio
|
||||
added_notification_ids.push_back(notification->id_);
|
||||
}
|
||||
|
||||
string_builder << " [" << NotificationGroupId(group->id_) << " from " << DialogId(group->chat_id_)
|
||||
string_builder << " [" << NotificationGroupId(group->id_) << " of type "
|
||||
<< get_notification_group_type(group->type_) << " from " << DialogId(group->chat_id_)
|
||||
<< "; total_count = " << group->total_count_ << ", restore " << added_notification_ids << "]\n";
|
||||
}
|
||||
return string_builder << ']';
|
||||
@ -165,7 +166,8 @@ td_api::object_ptr<td_api::updateActiveNotifications> NotificationManager::get_u
|
||||
}
|
||||
if (!notifications.empty()) {
|
||||
groups.push_back(td_api::make_object<td_api::notificationGroup>(
|
||||
group.first.group_id.get(), group.first.dialog_id.get(), group.second.total_count, std::move(notifications)));
|
||||
group.first.group_id.get(), get_notification_group_type_object(group.second.type),
|
||||
group.first.dialog_id.get(), group.second.total_count, std::move(notifications)));
|
||||
}
|
||||
}
|
||||
if (groups.empty()) {
|
||||
@ -228,6 +230,7 @@ NotificationManager::NotificationGroups::iterator NotificationManager::get_group
|
||||
}
|
||||
|
||||
NotificationGroup group;
|
||||
group.type = message_group.type;
|
||||
group.total_count = message_group.total_count;
|
||||
group.notifications = std::move(message_group.notifications);
|
||||
|
||||
@ -303,7 +306,8 @@ void NotificationManager::load_message_notifications_from_database(const Notific
|
||||
if (!G()->parameters().use_message_db) {
|
||||
return;
|
||||
}
|
||||
if (group.is_loaded_from_database || group.is_being_loaded_from_database || !group.contains_messages) {
|
||||
if (group.is_loaded_from_database || group.is_being_loaded_from_database ||
|
||||
group.type == NotificationGroupType::Calls) {
|
||||
return;
|
||||
}
|
||||
if (group.total_count == 0) {
|
||||
@ -455,8 +459,8 @@ void NotificationManager::add_notifications_to_group_begin(NotificationGroups::i
|
||||
|
||||
if (!added_notifications.empty()) {
|
||||
add_update_notification_group(td_api::make_object<td_api::updateNotificationGroup>(
|
||||
group_key.group_id.get(), group_key.dialog_id.get(), 0, true, group.total_count,
|
||||
std::move(added_notifications), vector<int32>()));
|
||||
group_key.group_id.get(), get_notification_group_type_object(group.type), group_key.dialog_id.get(), 0, true,
|
||||
group.total_count, std::move(added_notifications), vector<int32>()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -577,9 +581,10 @@ int32 NotificationManager::get_notification_delay_ms(DialogId dialog_id,
|
||||
return max(delay_ms - passed_time_ms, MIN_NOTIFICATION_DELAY_MS);
|
||||
}
|
||||
|
||||
void NotificationManager::add_notification(NotificationGroupId group_id, DialogId dialog_id, int32 date,
|
||||
DialogId notification_settings_dialog_id, bool is_silent,
|
||||
NotificationId notification_id, unique_ptr<NotificationType> type) {
|
||||
void NotificationManager::add_notification(NotificationGroupId group_id, NotificationGroupType group_type,
|
||||
DialogId dialog_id, int32 date, DialogId notification_settings_dialog_id,
|
||||
bool is_silent, NotificationId notification_id,
|
||||
unique_ptr<NotificationType> type) {
|
||||
if (is_disabled() || max_notification_group_count_ == 0) {
|
||||
return;
|
||||
}
|
||||
@ -589,19 +594,18 @@ void NotificationManager::add_notification(NotificationGroupId group_id, DialogI
|
||||
CHECK(notification_settings_dialog_id.is_valid());
|
||||
CHECK(notification_id.is_valid());
|
||||
CHECK(type != nullptr);
|
||||
VLOG(notifications) << "Add " << notification_id << " to " << group_id << " in " << dialog_id
|
||||
<< " with settings from " << notification_settings_dialog_id
|
||||
VLOG(notifications) << "Add " << notification_id << " to " << group_id << " of type " << group_type << " in "
|
||||
<< dialog_id << " with settings from " << notification_settings_dialog_id
|
||||
<< (is_silent ? " silently" : " with sound") << ": " << *type;
|
||||
|
||||
auto group_it = get_group_force(group_id);
|
||||
if (group_it == groups_.end()) {
|
||||
group_it = add_group(NotificationGroupKey(group_id, dialog_id, 0), NotificationGroup());
|
||||
if (type->get_call_id().is_valid()) {
|
||||
group_it->second.contains_messages = false;
|
||||
}
|
||||
}
|
||||
|
||||
CHECK(group_it->second.contains_messages == !type->get_call_id().is_valid());
|
||||
if (group_it->second.notifications.empty() && group_it->second.pending_notifications.empty()) {
|
||||
group_it->second.type = group_type;
|
||||
}
|
||||
CHECK(group_it->second.type == group_type);
|
||||
|
||||
PendingNotification notification;
|
||||
notification.date = date;
|
||||
@ -645,9 +649,9 @@ StringBuilder &operator<<(StringBuilder &string_builder, const NotificationUpdat
|
||||
added_notification_ids.push_back(notification->id_);
|
||||
}
|
||||
|
||||
return string_builder << "update[" << NotificationGroupId(p->notification_group_id_) << " from "
|
||||
<< DialogId(p->chat_id_) << " with settings from "
|
||||
<< DialogId(p->notification_settings_chat_id_)
|
||||
return string_builder << "update[" << NotificationGroupId(p->notification_group_id_) << " of type "
|
||||
<< get_notification_group_type(p->type_) << " from " << DialogId(p->chat_id_)
|
||||
<< " with settings from " << DialogId(p->notification_settings_chat_id_)
|
||||
<< (p->is_silent_ ? " silently" : " with sound") << "; total_count = " << p->total_count_
|
||||
<< ", add " << added_notification_ids << ", remove " << p->removed_notification_ids_;
|
||||
}
|
||||
@ -878,6 +882,7 @@ void NotificationManager::flush_pending_updates(int32 group_id, const char *sour
|
||||
if (updates[i - 1] != nullptr && updates[i - 1]->get_id() == td_api::updateNotificationGroup::ID) {
|
||||
VLOG(notifications) << "Move total_count from empty update " << cur_pos << " to update " << i;
|
||||
auto previous_update_ptr = static_cast<td_api::updateNotificationGroup *>(updates[i - 1].get());
|
||||
previous_update_ptr->type_ = std::move(update_ptr->type_);
|
||||
previous_update_ptr->total_count_ = update_ptr->total_count_;
|
||||
is_changed = true;
|
||||
update = nullptr;
|
||||
@ -991,6 +996,7 @@ void NotificationManager::flush_pending_updates(int32 group_id, const char *sour
|
||||
if (last_update_ptr->is_silent_ && !update_ptr->is_silent_) {
|
||||
last_update_ptr->is_silent_ = false;
|
||||
}
|
||||
last_update_ptr->type_ = std::move(update_ptr->type_);
|
||||
last_update_ptr->total_count_ = update_ptr->total_count_;
|
||||
append(last_update_ptr->added_notifications_, std::move(update_ptr->added_notifications_));
|
||||
append(last_update_ptr->removed_notification_ids_, std::move(update_ptr->removed_notification_ids_));
|
||||
@ -1077,9 +1083,9 @@ void NotificationManager::do_flush_pending_notifications(NotificationGroupKey &g
|
||||
|
||||
if (!added_notifications.empty()) {
|
||||
add_update_notification_group(td_api::make_object<td_api::updateNotificationGroup>(
|
||||
group_key.group_id.get(), group_key.dialog_id.get(), pending_notifications[0].settings_dialog_id.get(),
|
||||
pending_notifications[0].is_silent, group.total_count, std::move(added_notifications),
|
||||
std::move(removed_notification_ids)));
|
||||
group_key.group_id.get(), get_notification_group_type_object(group.type), group_key.dialog_id.get(),
|
||||
pending_notifications[0].settings_dialog_id.get(), pending_notifications[0].is_silent, group.total_count,
|
||||
std::move(added_notifications), std::move(removed_notification_ids)));
|
||||
} else {
|
||||
CHECK(removed_notification_ids.empty());
|
||||
}
|
||||
@ -1100,8 +1106,9 @@ void NotificationManager::send_remove_group_update(const NotificationGroupKey &g
|
||||
|
||||
if (!removed_notification_ids.empty()) {
|
||||
add_update_notification_group(td_api::make_object<td_api::updateNotificationGroup>(
|
||||
group_key.group_id.get(), group_key.dialog_id.get(), group_key.dialog_id.get(), true, group.total_count,
|
||||
vector<td_api::object_ptr<td_api::notification>>(), std::move(removed_notification_ids)));
|
||||
group_key.group_id.get(), get_notification_group_type_object(group.type), group_key.dialog_id.get(),
|
||||
group_key.dialog_id.get(), true, group.total_count, vector<td_api::object_ptr<td_api::notification>>(),
|
||||
std::move(removed_notification_ids)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1120,8 +1127,8 @@ void NotificationManager::send_add_group_update(const NotificationGroupKey &grou
|
||||
|
||||
if (!added_notifications.empty()) {
|
||||
add_update_notification_group(td_api::make_object<td_api::updateNotificationGroup>(
|
||||
group_key.group_id.get(), group_key.dialog_id.get(), 0, true, group.total_count, std::move(added_notifications),
|
||||
vector<int32>()));
|
||||
group_key.group_id.get(), get_notification_group_type_object(group.type), group_key.dialog_id.get(), 0, true,
|
||||
group.total_count, std::move(added_notifications), vector<int32>()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1193,7 +1200,8 @@ void NotificationManager::flush_pending_notifications(NotificationGroupId group_
|
||||
group.pending_notifications_flush_time = 0;
|
||||
group.pending_notifications.clear();
|
||||
// if we can delete a lot of notifications simultaneously
|
||||
if (group.notifications.size() > keep_notification_group_size_ + EXTRA_GROUP_SIZE && group.contains_messages) {
|
||||
if (group.notifications.size() > keep_notification_group_size_ + EXTRA_GROUP_SIZE &&
|
||||
group.type != NotificationGroupType::Calls) {
|
||||
// keep only keep_notification_group_size_ last notifications in memory
|
||||
group.notifications.erase(group.notifications.begin(), group.notifications.end() - keep_notification_group_size_);
|
||||
group.is_loaded_from_database = false;
|
||||
@ -1291,8 +1299,8 @@ void NotificationManager::on_notifications_removed(
|
||||
if (is_updated) {
|
||||
// group is still visible
|
||||
add_update_notification_group(td_api::make_object<td_api::updateNotificationGroup>(
|
||||
group_key.group_id.get(), group_key.dialog_id.get(), 0, true, group.total_count,
|
||||
std::move(added_notifications), std::move(removed_notification_ids)));
|
||||
group_key.group_id.get(), get_notification_group_type_object(group.type), group_key.dialog_id.get(), 0, true,
|
||||
group.total_count, std::move(added_notifications), std::move(removed_notification_ids)));
|
||||
} else {
|
||||
// group needs to be removed
|
||||
send_remove_group_update(group_key, group, std::move(removed_notification_ids));
|
||||
@ -1383,7 +1391,7 @@ void NotificationManager::remove_notification(NotificationGroupId group_id, Noti
|
||||
return promise.set_value(Unit());
|
||||
}
|
||||
|
||||
if (!is_permanent && group_it->second.contains_messages) {
|
||||
if (!is_permanent && group_it->second.type != NotificationGroupType::Calls) {
|
||||
td_->messages_manager_->remove_message_notification(group_it->first.dialog_id, group_id, notification_id);
|
||||
}
|
||||
|
||||
@ -1411,7 +1419,8 @@ void NotificationManager::remove_notification(NotificationGroupId group_id, Noti
|
||||
}
|
||||
|
||||
bool is_total_count_changed = false;
|
||||
if ((group_it->second.contains_messages && is_permanent) || (!group_it->second.contains_messages && is_found)) {
|
||||
if ((group_it->second.type != NotificationGroupType::Calls && is_permanent) ||
|
||||
(group_it->second.type == NotificationGroupType::Calls && is_found)) {
|
||||
if (group_it->second.total_count == 0) {
|
||||
LOG(ERROR) << "Total notification count became negative in " << group_id << " after removing " << notification_id;
|
||||
} else {
|
||||
@ -1478,7 +1487,7 @@ void NotificationManager::remove_notification_group(NotificationGroupId group_id
|
||||
if (max_notification_id.get() > current_notification_id_.get()) {
|
||||
max_notification_id = current_notification_id_;
|
||||
}
|
||||
if (group_it->second.contains_messages) {
|
||||
if (group_it->second.type != NotificationGroupType::Calls) {
|
||||
td_->messages_manager_->remove_message_notifications(group_it->first.dialog_id, group_id, max_notification_id);
|
||||
}
|
||||
}
|
||||
@ -1529,7 +1538,7 @@ void NotificationManager::remove_notification_group(NotificationGroupId group_id
|
||||
group_it->second.notifications.erase(group_it->second.notifications.begin(),
|
||||
group_it->second.notifications.begin() + notification_delete_end);
|
||||
}
|
||||
if (!group_it->second.contains_messages) {
|
||||
if (group_it->second.type == NotificationGroupType::Calls) {
|
||||
new_total_count = static_cast<int32>(group_it->second.notifications.size());
|
||||
}
|
||||
if (group_it->second.total_count == new_total_count) {
|
||||
@ -1624,8 +1633,8 @@ void NotificationManager::add_call_notification(DialogId dialog_id, CallId call_
|
||||
auto notification_id = get_next_notification_id();
|
||||
active_notifications.push_back(ActiveCallNotification{call_id, notification_id});
|
||||
|
||||
add_notification(group_id, dialog_id, G()->unix_time() + 120, dialog_id, false, notification_id,
|
||||
create_new_call_notification(call_id));
|
||||
add_notification(group_id, NotificationGroupType::Calls, dialog_id, G()->unix_time() + 120, dialog_id, false,
|
||||
notification_id, create_new_call_notification(call_id));
|
||||
}
|
||||
|
||||
void NotificationManager::remove_call_notification(DialogId dialog_id, CallId call_id) {
|
||||
@ -1665,7 +1674,7 @@ void NotificationManager::remove_call_notification(DialogId dialog_id, CallId ca
|
||||
CHECK(group_it->second.total_count == 0);
|
||||
CHECK(group_it->second.notifications.empty());
|
||||
CHECK(group_it->second.pending_notifications.empty());
|
||||
CHECK(!group_it->second.contains_messages);
|
||||
CHECK(group_it->second.type == NotificationGroupType::Calls);
|
||||
CHECK(!group_it->second.is_being_loaded_from_database);
|
||||
CHECK(pending_updates_.count(group_id.get()) == 0);
|
||||
delete_group(std::move(group_it));
|
||||
@ -1803,8 +1812,9 @@ void NotificationManager::on_notification_group_size_max_changed() {
|
||||
}
|
||||
}
|
||||
auto update = td_api::make_object<td_api::updateNotificationGroup>(
|
||||
group_key.group_id.get(), group_key.dialog_id.get(), group_key.dialog_id.get(), true, group.total_count,
|
||||
std::move(added_notifications), std::move(removed_notification_ids));
|
||||
group_key.group_id.get(), get_notification_group_type_object(group.type), group_key.dialog_id.get(),
|
||||
group_key.dialog_id.get(), true, group.total_count, std::move(added_notifications),
|
||||
std::move(removed_notification_ids));
|
||||
VLOG(notifications) << "Send " << as_notification_update(update.get());
|
||||
send_closure(G()->td(), &Td::send_update, std::move(update));
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "td/telegram/Notification.h"
|
||||
#include "td/telegram/NotificationGroupId.h"
|
||||
#include "td/telegram/NotificationGroupKey.h"
|
||||
#include "td/telegram/NotificationGroupType.h"
|
||||
#include "td/telegram/NotificationId.h"
|
||||
#include "td/telegram/NotificationType.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
@ -57,7 +58,7 @@ class NotificationManager : public Actor {
|
||||
|
||||
void load_group_force(NotificationGroupId group_id);
|
||||
|
||||
void add_notification(NotificationGroupId group_id, DialogId dialog_id, int32 date,
|
||||
void add_notification(NotificationGroupId group_id, NotificationGroupType group_type, DialogId dialog_id, int32 date,
|
||||
DialogId notification_settings_dialog_id, bool is_silent, NotificationId notification_id,
|
||||
unique_ptr<NotificationType> type);
|
||||
|
||||
@ -121,9 +122,9 @@ class NotificationManager : public Actor {
|
||||
|
||||
struct NotificationGroup {
|
||||
int32 total_count = 0;
|
||||
NotificationGroupType type = NotificationGroupType::Calls;
|
||||
bool is_loaded_from_database = false;
|
||||
bool is_being_loaded_from_database = false;
|
||||
bool contains_messages = true;
|
||||
|
||||
vector<Notification> notifications;
|
||||
|
||||
|
@ -20,10 +20,6 @@ class NotificationTypeMessage : public NotificationType {
|
||||
return message_id_;
|
||||
}
|
||||
|
||||
CallId get_call_id() const override {
|
||||
return CallId();
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const override {
|
||||
auto message_object = G()->td().get_actor_unsafe()->messages_manager_->get_message_object({dialog_id, message_id_});
|
||||
if (message_object == nullptr) {
|
||||
@ -56,10 +52,6 @@ class NotificationTypeSecretChat : public NotificationType {
|
||||
return MessageId();
|
||||
}
|
||||
|
||||
CallId get_call_id() const override {
|
||||
return CallId();
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const override {
|
||||
return td_api::make_object<td_api::notificationTypeNewSecretChat>();
|
||||
}
|
||||
@ -86,10 +78,6 @@ class NotificationTypeCall : public NotificationType {
|
||||
return MessageId::max();
|
||||
}
|
||||
|
||||
CallId get_call_id() const override {
|
||||
return call_id_;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const override {
|
||||
return td_api::make_object<td_api::notificationTypeNewCall>(call_id_.get());
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ class NotificationType {
|
||||
|
||||
virtual MessageId get_message_id() const = 0;
|
||||
|
||||
virtual CallId get_call_id() const = 0;
|
||||
|
||||
virtual td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const = 0;
|
||||
|
||||
virtual StringBuilder &to_string_builder(StringBuilder &string_builder) const = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user