Output exact reason when push notification is ignored.
GitOrigin-RevId: 5d1f99af1e767f79d4a66329c9ffb812e7c9e6cb
This commit is contained in:
parent
521227a2f6
commit
aa9781bd71
@ -18198,31 +18198,36 @@ NotificationGroupId MessagesManager::get_dialog_notification_group_id(DialogId d
|
||||
return group_info.group_id;
|
||||
}
|
||||
|
||||
MessagesManager::MessagePushNotificationInfo MessagesManager::get_message_push_notification_info(
|
||||
Result<MessagesManager::MessagePushNotificationInfo> MessagesManager::get_message_push_notification_info(
|
||||
DialogId dialog_id, MessageId message_id, int64 random_id, UserId sender_user_id, int32 date, bool contains_mention,
|
||||
bool is_pinned) {
|
||||
init();
|
||||
|
||||
if (dialog_id == get_my_dialog_id() || td_->auth_manager_->is_bot()) {
|
||||
return {};
|
||||
if (dialog_id == get_my_dialog_id()) {
|
||||
return Status::Error("Ignore notification in chat with self");
|
||||
}
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return Status::Error("Ignore notification sent to bot");
|
||||
}
|
||||
|
||||
if (sender_user_id.is_valid() && !td_->contacts_manager_->have_user(sender_user_id)) {
|
||||
// allow messages from unknown sender, we will use only sender's name and photo
|
||||
// return {};
|
||||
// return Status::Error("Ignore notification from unknown user");
|
||||
}
|
||||
|
||||
Dialog *d = get_dialog_force(dialog_id);
|
||||
if (d == nullptr) {
|
||||
return {};
|
||||
return Status::Error("Ignore notification in unknown chat");
|
||||
;
|
||||
}
|
||||
if (message_id.is_valid() && message_id.get() <= d->last_new_message_id.get()) {
|
||||
return {};
|
||||
return Status::Error("Ignore notification about known message");
|
||||
;
|
||||
}
|
||||
if (random_id != 0) {
|
||||
CHECK(dialog_id.get_type() == DialogType::SecretChat);
|
||||
if (get_message_id_by_random_id(d, random_id, "need_message_push_notification").is_valid()) {
|
||||
return {};
|
||||
return Status::Error("Ignore notification about known secret message");
|
||||
}
|
||||
}
|
||||
|
||||
@ -18243,17 +18248,17 @@ MessagesManager::MessagePushNotificationInfo MessagesManager::get_message_push_n
|
||||
int32 mute_until;
|
||||
std::tie(have_settings, mute_until) = get_dialog_mute_until(settings_dialog_id, settings_dialog);
|
||||
if (have_settings && mute_until <= date) {
|
||||
return {};
|
||||
return Status::Error("Ignore notification in muted chat");
|
||||
}
|
||||
|
||||
if (is_dialog_message_notification_disabled(settings_dialog_id, date)) {
|
||||
return {};
|
||||
return Status::Error("Ignore notification in chat, because notifications are disabled in the chat");
|
||||
}
|
||||
|
||||
auto group_id = get_dialog_notification_group_id(
|
||||
dialog_id, contains_mention ? d->mention_notification_group : d->message_notification_group);
|
||||
if (!group_id.is_valid()) {
|
||||
return {};
|
||||
return Status::Error("Can't assign notification group ID");
|
||||
}
|
||||
|
||||
MessagePushNotificationInfo result;
|
||||
|
@ -696,9 +696,10 @@ class MessagesManager : public Actor {
|
||||
NotificationGroupType group_type = NotificationGroupType::Calls;
|
||||
DialogId settings_dialog_id;
|
||||
};
|
||||
MessagePushNotificationInfo get_message_push_notification_info(DialogId dialog_id, MessageId message_id,
|
||||
int64 random_id, UserId sender_user_id, int32 date,
|
||||
bool contains_mention, bool is_pinned);
|
||||
Result<MessagePushNotificationInfo> get_message_push_notification_info(DialogId dialog_id, MessageId message_id,
|
||||
int64 random_id, UserId sender_user_id,
|
||||
int32 date, bool contains_mention,
|
||||
bool is_pinned);
|
||||
|
||||
struct MessageNotificationGroup {
|
||||
DialogId dialog_id;
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include "td/telegram/NotificationManager.h"
|
||||
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ChatId.h"
|
||||
#include "td/telegram/ChannelId.h"
|
||||
#include "td/telegram/ChatId.h"
|
||||
#include "td/telegram/ConfigShared.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DeviceTokenManager.h"
|
||||
@ -2783,14 +2783,17 @@ Status NotificationManager::process_message_push_notification(DialogId dialog_id
|
||||
}
|
||||
|
||||
auto is_pinned = begins_with(loc_key, "PINNED_");
|
||||
auto info = td_->messages_manager_->get_message_push_notification_info(
|
||||
auto r_info = td_->messages_manager_->get_message_push_notification_info(
|
||||
dialog_id, message_id, random_id, sender_user_id, date, contains_mention, is_pinned);
|
||||
if (!info.group_id.is_valid()) {
|
||||
if (r_info.is_error()) {
|
||||
VLOG(notifications) << "Don't need message push notification for " << message_id << "/" << random_id << " from "
|
||||
<< dialog_id;
|
||||
<< dialog_id << ": " << r_info.error();
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
auto info = r_info.move_as_ok();
|
||||
CHECK(info.group_id.is_valid());
|
||||
|
||||
if (dialog_id.get_type() == DialogType::SecretChat) {
|
||||
VLOG(notifications) << "Skep notification in secret " << dialog_id;
|
||||
// TODO support secret chat notifications
|
||||
|
Loading…
x
Reference in New Issue
Block a user