Add td_api::notification.is_silent.
GitOrigin-RevId: bab4a0c401913177b9fc794ee510c912be3f2727
This commit is contained in:
parent
c74263ce3d
commit
0e2898b81e
@ -2165,8 +2165,9 @@ notificationGroupTypeSecretChat = NotificationGroupType;
|
|||||||
notificationGroupTypeCalls = NotificationGroupType;
|
notificationGroupTypeCalls = NotificationGroupType;
|
||||||
|
|
||||||
|
|
||||||
//@description Contains information about a notification @id Unique persistent identifier of this notification @date Notification date @type Notification type
|
//@description Contains information about a notification @id Unique persistent identifier of this notification @date Notification date
|
||||||
notification id:int32 date:int32 type:NotificationType = Notification;
|
//@is_silent True, if the notification was initially silent @type Notification type
|
||||||
|
notification id:int32 date:int32 is_silent:Bool type:NotificationType = Notification;
|
||||||
|
|
||||||
//@description Describes a group of notifications @id Unique persistent auto-incremented from 1 identifier of the notification group @type Type of the group
|
//@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
|
//@chat_id Identifier of a chat to which all notifications in the group belong
|
||||||
|
Binary file not shown.
@ -19412,7 +19412,7 @@ MessagesManager::MessageNotificationGroup MessagesManager::get_message_notificat
|
|||||||
result.type = NotificationGroupType::SecretChat;
|
result.type = NotificationGroupType::SecretChat;
|
||||||
result.notifications.emplace_back(d->new_secret_chat_notification_id,
|
result.notifications.emplace_back(d->new_secret_chat_notification_id,
|
||||||
td_->contacts_manager_->get_secret_chat_date(d->dialog_id.get_secret_chat_id()),
|
td_->contacts_manager_->get_secret_chat_date(d->dialog_id.get_secret_chat_id()),
|
||||||
create_new_secret_chat_notification());
|
false, create_new_secret_chat_notification());
|
||||||
} else {
|
} else {
|
||||||
result.type = from_mentions ? NotificationGroupType::Mentions : NotificationGroupType::Messages;
|
result.type = from_mentions ? NotificationGroupType::Mentions : NotificationGroupType::Messages;
|
||||||
result.notifications = get_message_notifications_from_database_force(
|
result.notifications = get_message_notifications_from_database_force(
|
||||||
@ -19476,7 +19476,8 @@ void MessagesManager::try_add_pinned_message_notification(Dialog *d, vector<Noti
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto pos = res.size();
|
auto pos = res.size();
|
||||||
res.emplace_back(m->notification_id, m->date, create_new_message_notification(message_id));
|
res.emplace_back(m->notification_id, m->date, m->disable_notification,
|
||||||
|
create_new_message_notification(message_id));
|
||||||
while (pos > 0 && res[pos - 1].type->get_message_id().get() < message_id.get()) {
|
while (pos > 0 && res[pos - 1].type->get_message_id().get() < message_id.get()) {
|
||||||
std::swap(res[pos - 1], res[pos]);
|
std::swap(res[pos - 1], res[pos]);
|
||||||
pos--;
|
pos--;
|
||||||
@ -19590,7 +19591,8 @@ vector<Notification> MessagesManager::get_message_notifications_from_database_fo
|
|||||||
|
|
||||||
if (is_correct) {
|
if (is_correct) {
|
||||||
// skip mention messages returned among unread messages
|
// skip mention messages returned among unread messages
|
||||||
res.emplace_back(m->notification_id, m->date, create_new_message_notification(m->message_id));
|
res.emplace_back(m->notification_id, m->date, m->disable_notification,
|
||||||
|
create_new_message_notification(m->message_id));
|
||||||
} else {
|
} else {
|
||||||
remove_message_notification_id(d, m, true, false);
|
remove_message_notification_id(d, m, true, false);
|
||||||
on_message_changed(d, m, false, "get_message_notifications_from_database_force");
|
on_message_changed(d, m, false, "get_message_notifications_from_database_force");
|
||||||
@ -19694,7 +19696,7 @@ void MessagesManager::get_message_notifications_from_database(DialogId dialog_id
|
|||||||
vector<Notification> notifications;
|
vector<Notification> notifications;
|
||||||
if (!from_mentions && d->new_secret_chat_notification_id.get() < from_notification_id.get()) {
|
if (!from_mentions && d->new_secret_chat_notification_id.get() < from_notification_id.get()) {
|
||||||
notifications.emplace_back(d->new_secret_chat_notification_id,
|
notifications.emplace_back(d->new_secret_chat_notification_id,
|
||||||
td_->contacts_manager_->get_secret_chat_date(d->dialog_id.get_secret_chat_id()),
|
td_->contacts_manager_->get_secret_chat_date(d->dialog_id.get_secret_chat_id()), false,
|
||||||
create_new_secret_chat_notification());
|
create_new_secret_chat_notification());
|
||||||
}
|
}
|
||||||
return promise.set_value(std::move(notifications));
|
return promise.set_value(std::move(notifications));
|
||||||
@ -19833,7 +19835,8 @@ void MessagesManager::on_get_message_notifications_from_database(DialogId dialog
|
|||||||
|
|
||||||
if (is_correct) {
|
if (is_correct) {
|
||||||
// skip mention messages returned among unread messages
|
// skip mention messages returned among unread messages
|
||||||
res.emplace_back(m->notification_id, m->date, create_new_message_notification(m->message_id));
|
res.emplace_back(m->notification_id, m->date, m->disable_notification,
|
||||||
|
create_new_message_notification(m->message_id));
|
||||||
} else {
|
} else {
|
||||||
remove_message_notification_id(d, m, true, false);
|
remove_message_notification_id(d, m, true, false);
|
||||||
on_message_changed(d, m, false, "on_get_message_notifications_from_database");
|
on_message_changed(d, m, false, "on_get_message_notifications_from_database");
|
||||||
@ -20262,7 +20265,7 @@ bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool f
|
|||||||
bool is_silent = m->disable_notification || m->message_id.get() <= d->max_notification_message_id.get();
|
bool is_silent = m->disable_notification || m->message_id.get() <= d->max_notification_message_id.get();
|
||||||
send_closure_later(G()->notification_manager(), &NotificationManager::add_notification, notification_group_id,
|
send_closure_later(G()->notification_manager(), &NotificationManager::add_notification, notification_group_id,
|
||||||
from_mentions ? NotificationGroupType::Mentions : NotificationGroupType::Messages, d->dialog_id,
|
from_mentions ? NotificationGroupType::Mentions : NotificationGroupType::Messages, d->dialog_id,
|
||||||
m->date, settings_dialog_id, is_silent, min_delay_ms, m->notification_id,
|
m->date, settings_dialog_id, m->disable_notification, is_silent, min_delay_ms, m->notification_id,
|
||||||
create_new_message_notification(m->message_id), "add_new_message_notification");
|
create_new_message_notification(m->message_id), "add_new_message_notification");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -24750,8 +24753,8 @@ void MessagesManager::force_create_dialog(DialogId dialog_id, const char *source
|
|||||||
VLOG(notifications) << "Create " << d->new_secret_chat_notification_id << " with " << secret_chat_id;
|
VLOG(notifications) << "Create " << d->new_secret_chat_notification_id << " with " << secret_chat_id;
|
||||||
send_closure_later(G()->notification_manager(), &NotificationManager::add_notification,
|
send_closure_later(G()->notification_manager(), &NotificationManager::add_notification,
|
||||||
notification_group_id, NotificationGroupType::SecretChat, dialog_id, date, dialog_id,
|
notification_group_id, NotificationGroupType::SecretChat, dialog_id, date, dialog_id,
|
||||||
false, 0, d->new_secret_chat_notification_id, create_new_secret_chat_notification(),
|
false, false, 0, d->new_secret_chat_notification_id,
|
||||||
"add_new_secret_chat_notification");
|
create_new_secret_chat_notification(), "add_new_secret_chat_notification");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,11 @@ class Notification {
|
|||||||
public:
|
public:
|
||||||
NotificationId notification_id;
|
NotificationId notification_id;
|
||||||
int32 date = 0;
|
int32 date = 0;
|
||||||
|
bool is_silent = false;
|
||||||
unique_ptr<NotificationType> type;
|
unique_ptr<NotificationType> type;
|
||||||
|
|
||||||
Notification(NotificationId notification_id, int32 date, unique_ptr<NotificationType> type)
|
Notification(NotificationId notification_id, int32 date, bool is_silent, unique_ptr<NotificationType> type)
|
||||||
: notification_id(notification_id), date(date), type(std::move(type)) {
|
: notification_id(notification_id), date(date), is_silent(is_silent), type(std::move(type)) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -31,12 +32,13 @@ inline td_api::object_ptr<td_api::notification> get_notification_object(DialogId
|
|||||||
const Notification ¬ification) {
|
const Notification ¬ification) {
|
||||||
CHECK(notification.type != nullptr);
|
CHECK(notification.type != nullptr);
|
||||||
return td_api::make_object<td_api::notification>(notification.notification_id.get(), notification.date,
|
return td_api::make_object<td_api::notification>(notification.notification_id.get(), notification.date,
|
||||||
|
notification.is_silent,
|
||||||
notification.type->get_notification_type_object(dialog_id));
|
notification.type->get_notification_type_object(dialog_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline StringBuilder &operator<<(StringBuilder &sb, const Notification ¬ification) {
|
inline StringBuilder &operator<<(StringBuilder &sb, const Notification ¬ification) {
|
||||||
return sb << "notification[" << notification.notification_id << ", " << notification.date << ", "
|
return sb << "notification[" << notification.notification_id << ", " << notification.date << ", "
|
||||||
<< *notification.type << ']';
|
<< notification.is_silent << ", " << *notification.type << ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -842,8 +842,9 @@ int32 NotificationManager::get_notification_delay_ms(DialogId dialog_id, const P
|
|||||||
|
|
||||||
void NotificationManager::add_notification(NotificationGroupId group_id, NotificationGroupType group_type,
|
void NotificationManager::add_notification(NotificationGroupId group_id, NotificationGroupType group_type,
|
||||||
DialogId dialog_id, int32 date, DialogId notification_settings_dialog_id,
|
DialogId dialog_id, int32 date, DialogId notification_settings_dialog_id,
|
||||||
bool is_silent, int32 min_delay_ms, NotificationId notification_id,
|
bool initial_is_silent, bool is_silent, int32 min_delay_ms,
|
||||||
unique_ptr<NotificationType> type, const char *source) {
|
NotificationId notification_id, unique_ptr<NotificationType> type,
|
||||||
|
const char *source) {
|
||||||
if (is_disabled() || max_notification_group_count_ == 0) {
|
if (is_disabled() || max_notification_group_count_ == 0) {
|
||||||
on_notification_removed(notification_id);
|
on_notification_removed(notification_id);
|
||||||
return;
|
return;
|
||||||
@ -890,6 +891,7 @@ void NotificationManager::add_notification(NotificationGroupId group_id, Notific
|
|||||||
PendingNotification notification;
|
PendingNotification notification;
|
||||||
notification.date = date;
|
notification.date = date;
|
||||||
notification.settings_dialog_id = notification_settings_dialog_id;
|
notification.settings_dialog_id = notification_settings_dialog_id;
|
||||||
|
notification.initial_is_silent = initial_is_silent;
|
||||||
notification.is_silent = is_silent;
|
notification.is_silent = is_silent;
|
||||||
notification.notification_id = notification_id;
|
notification.notification_id = notification_id;
|
||||||
notification.type = std::move(type);
|
notification.type = std::move(type);
|
||||||
@ -1385,7 +1387,7 @@ bool NotificationManager::do_flush_pending_notifications(NotificationGroupKey &g
|
|||||||
added_notifications.reserve(pending_notifications.size());
|
added_notifications.reserve(pending_notifications.size());
|
||||||
for (auto &pending_notification : pending_notifications) {
|
for (auto &pending_notification : pending_notifications) {
|
||||||
Notification notification(pending_notification.notification_id, pending_notification.date,
|
Notification notification(pending_notification.notification_id, pending_notification.date,
|
||||||
std::move(pending_notification.type));
|
pending_notification.initial_is_silent, std::move(pending_notification.type));
|
||||||
added_notifications.push_back(get_notification_object(group_key.dialog_id, notification));
|
added_notifications.push_back(get_notification_object(group_key.dialog_id, notification));
|
||||||
if (added_notifications.back()->type_ == nullptr) {
|
if (added_notifications.back()->type_ == nullptr) {
|
||||||
added_notifications.pop_back();
|
added_notifications.pop_back();
|
||||||
@ -1513,7 +1515,7 @@ void NotificationManager::flush_pending_notifications(NotificationGroupId group_
|
|||||||
group.total_count += narrow_cast<int32>(group.pending_notifications.size());
|
group.total_count += narrow_cast<int32>(group.pending_notifications.size());
|
||||||
for (auto &pending_notification : group.pending_notifications) {
|
for (auto &pending_notification : group.pending_notifications) {
|
||||||
group.notifications.emplace_back(pending_notification.notification_id, pending_notification.date,
|
group.notifications.emplace_back(pending_notification.notification_id, pending_notification.date,
|
||||||
std::move(pending_notification.type));
|
pending_notification.initial_is_silent, std::move(pending_notification.type));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!was_updated) {
|
if (!was_updated) {
|
||||||
@ -2308,8 +2310,8 @@ void NotificationManager::add_call_notification(DialogId dialog_id, CallId call_
|
|||||||
}
|
}
|
||||||
active_notifications.push_back(ActiveCallNotification{call_id, notification_id});
|
active_notifications.push_back(ActiveCallNotification{call_id, notification_id});
|
||||||
|
|
||||||
add_notification(group_id, NotificationGroupType::Calls, dialog_id, G()->unix_time() + 120, dialog_id, false, 0,
|
add_notification(group_id, NotificationGroupType::Calls, dialog_id, G()->unix_time() + 120, dialog_id, false, false,
|
||||||
notification_id, create_new_call_notification(call_id), "add_call_notification");
|
0, notification_id, create_new_call_notification(call_id), "add_call_notification");
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::remove_call_notification(DialogId dialog_id, CallId call_id) {
|
void NotificationManager::remove_call_notification(DialogId dialog_id, CallId call_id) {
|
||||||
@ -3375,9 +3377,9 @@ Status NotificationManager::process_push_notification_payload(string payload, bo
|
|||||||
} else {
|
} else {
|
||||||
bool is_silent = has_json_object_field(custom, "silent");
|
bool is_silent = has_json_object_field(custom, "silent");
|
||||||
add_message_push_notification(dialog_id, MessageId(server_message_id), random_id, sender_user_id,
|
add_message_push_notification(dialog_id, MessageId(server_message_id), random_id, sender_user_id,
|
||||||
std::move(sender_name), sent_date, contains_mention, is_silent, std::move(loc_key),
|
std::move(sender_name), sent_date, contains_mention, is_silent, is_silent,
|
||||||
std::move(arg), std::move(attached_photo), std::move(attached_document),
|
std::move(loc_key), std::move(arg), std::move(attached_photo),
|
||||||
NotificationId(), 0, std::move(promise));
|
std::move(attached_document), NotificationId(), 0, std::move(promise));
|
||||||
}
|
}
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
@ -3499,8 +3501,8 @@ class NotificationManager::AddMessagePushNotificationLogEvent {
|
|||||||
|
|
||||||
void NotificationManager::add_message_push_notification(DialogId dialog_id, MessageId message_id, int64 random_id,
|
void NotificationManager::add_message_push_notification(DialogId dialog_id, MessageId message_id, int64 random_id,
|
||||||
UserId sender_user_id, string sender_name, int32 date,
|
UserId sender_user_id, string sender_name, int32 date,
|
||||||
bool contains_mention, bool is_silent, string loc_key,
|
bool contains_mention, bool initial_is_silent, bool is_silent,
|
||||||
string arg, Photo photo, Document document,
|
string loc_key, string arg, Photo photo, Document document,
|
||||||
NotificationId notification_id, uint64 logevent_id,
|
NotificationId notification_id, uint64 logevent_id,
|
||||||
Promise<Unit> promise) {
|
Promise<Unit> promise) {
|
||||||
auto is_pinned = begins_with(loc_key, "PINNED_");
|
auto is_pinned = begins_with(loc_key, "PINNED_");
|
||||||
@ -3560,8 +3562,8 @@ void NotificationManager::add_message_push_notification(DialogId dialog_id, Mess
|
|||||||
|
|
||||||
if (logevent_id == 0 && G()->parameters().use_message_db) {
|
if (logevent_id == 0 && G()->parameters().use_message_db) {
|
||||||
AddMessagePushNotificationLogEvent logevent{
|
AddMessagePushNotificationLogEvent logevent{
|
||||||
dialog_id, message_id, random_id, sender_user_id, sender_name, date, contains_mention,
|
dialog_id, message_id, random_id, sender_user_id, sender_name, date, contains_mention,
|
||||||
is_silent, loc_key, arg, photo, document, notification_id};
|
initial_is_silent, loc_key, arg, photo, document, notification_id};
|
||||||
auto storer = LogEventStorerImpl<AddMessagePushNotificationLogEvent>(logevent);
|
auto storer = LogEventStorerImpl<AddMessagePushNotificationLogEvent>(logevent);
|
||||||
logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::AddMessagePushNotification, storer);
|
logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::AddMessagePushNotification, storer);
|
||||||
}
|
}
|
||||||
@ -3584,7 +3586,8 @@ void NotificationManager::add_message_push_notification(DialogId dialog_id, Mess
|
|||||||
<< " with arg " << arg << ", photo " << photo << " and document " << document << " to "
|
<< " with arg " << arg << ", photo " << photo << " and document " << document << " to "
|
||||||
<< group_id << " of type " << group_type << " with settings from " << settings_dialog_id;
|
<< group_id << " of type " << group_type << " with settings from " << settings_dialog_id;
|
||||||
|
|
||||||
add_notification(group_id, group_type, dialog_id, date, settings_dialog_id, is_silent, 0, notification_id,
|
add_notification(group_id, group_type, dialog_id, date, settings_dialog_id, initial_is_silent, is_silent, 0,
|
||||||
|
notification_id,
|
||||||
create_new_push_message_notification(sender_user_id, message_id, std::move(loc_key), std::move(arg),
|
create_new_push_message_notification(sender_user_id, message_id, std::move(loc_key), std::move(arg),
|
||||||
std::move(photo), std::move(document)),
|
std::move(photo), std::move(document)),
|
||||||
"add_message_push_notification");
|
"add_message_push_notification");
|
||||||
@ -4030,9 +4033,9 @@ void NotificationManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
|||||||
|
|
||||||
add_message_push_notification(
|
add_message_push_notification(
|
||||||
log_event.dialog_id_, log_event.message_id_, log_event.random_id_, log_event.sender_user_id_,
|
log_event.dialog_id_, log_event.message_id_, log_event.random_id_, log_event.sender_user_id_,
|
||||||
log_event.sender_name_, log_event.date_, log_event.contains_mention_, true, log_event.loc_key_,
|
log_event.sender_name_, log_event.date_, log_event.contains_mention_, log_event.is_silent_, true,
|
||||||
log_event.arg_, log_event.photo_, log_event.document_, log_event.notification_id_, event.id_,
|
log_event.loc_key_, log_event.arg_, log_event.photo_, log_event.document_, log_event.notification_id_,
|
||||||
PromiseCreator::lambda([](Result<Unit> result) {
|
event.id_, PromiseCreator::lambda([](Result<Unit> result) {
|
||||||
if (result.is_error() && result.error().code() != 200 && result.error().code() != 406) {
|
if (result.is_error() && result.error().code() != 200 && result.error().code() != 406) {
|
||||||
LOG(ERROR) << "Receive error " << result.error() << ", while processing message push notification";
|
LOG(ERROR) << "Receive error " << result.error() << ", while processing message push notification";
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,9 @@ class NotificationManager : public Actor {
|
|||||||
void load_group_force(NotificationGroupId group_id);
|
void load_group_force(NotificationGroupId group_id);
|
||||||
|
|
||||||
void add_notification(NotificationGroupId group_id, NotificationGroupType group_type, 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, int32 min_delay_ms,
|
DialogId notification_settings_dialog_id, bool initial_is_silent, bool is_silent,
|
||||||
NotificationId notification_id, unique_ptr<NotificationType> type, const char *source);
|
int32 min_delay_ms, NotificationId notification_id, unique_ptr<NotificationType> type,
|
||||||
|
const char *source);
|
||||||
|
|
||||||
void edit_notification(NotificationGroupId group_id, NotificationId notification_id,
|
void edit_notification(NotificationGroupId group_id, NotificationId notification_id,
|
||||||
unique_ptr<NotificationType> type);
|
unique_ptr<NotificationType> type);
|
||||||
@ -154,6 +155,7 @@ class NotificationManager : public Actor {
|
|||||||
struct PendingNotification {
|
struct PendingNotification {
|
||||||
int32 date = 0;
|
int32 date = 0;
|
||||||
DialogId settings_dialog_id;
|
DialogId settings_dialog_id;
|
||||||
|
bool initial_is_silent = false;
|
||||||
bool is_silent = false;
|
bool is_silent = false;
|
||||||
NotificationId notification_id;
|
NotificationId notification_id;
|
||||||
unique_ptr<NotificationType> type;
|
unique_ptr<NotificationType> type;
|
||||||
@ -303,8 +305,8 @@ class NotificationManager : public Actor {
|
|||||||
Status process_push_notification_payload(string payload, bool was_encrypted, Promise<Unit> &promise);
|
Status process_push_notification_payload(string payload, bool was_encrypted, Promise<Unit> &promise);
|
||||||
|
|
||||||
void add_message_push_notification(DialogId dialog_id, MessageId message_id, int64 random_id, UserId sender_user_id,
|
void add_message_push_notification(DialogId dialog_id, MessageId message_id, int64 random_id, UserId sender_user_id,
|
||||||
string sender_name, int32 date, bool contains_mention, bool is_silent,
|
string sender_name, int32 date, bool contains_mention, bool initial_is_silent,
|
||||||
string loc_key, string arg, Photo photo, Document document,
|
bool is_silent, string loc_key, string arg, Photo photo, Document document,
|
||||||
NotificationId notification_id, uint64 logevent_id, Promise<Unit> promise);
|
NotificationId notification_id, uint64 logevent_id, Promise<Unit> promise);
|
||||||
|
|
||||||
void edit_message_push_notification(DialogId dialog_id, MessageId message_id, int32 edit_date, string loc_key,
|
void edit_message_push_notification(DialogId dialog_id, MessageId message_id, int32 edit_date, string loc_key,
|
||||||
|
Reference in New Issue
Block a user