diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index c60b7391..caa7aef6 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -11776,7 +11776,8 @@ void MessagesManager::on_get_common_dialogs(UserId user_id, int32 offset_chat_id td_->contacts_manager_->on_update_user_common_chat_count(user_id, total_count); auto &common_dialogs = found_common_dialogs_[user_id]; - if (common_dialogs.is_outdated && offset_chat_id == 0 && common_dialogs.dialog_ids.size() < static_cast(MAX_GET_DIALOGS)) { + if (common_dialogs.is_outdated && offset_chat_id == 0 && + common_dialogs.dialog_ids.size() < static_cast(MAX_GET_DIALOGS)) { // drop outdated cache if possible common_dialogs = CommonDialogs(); } @@ -18287,7 +18288,7 @@ Result MessagesManager::get_messag Dialog *d = get_dialog_force(dialog_id); if (d == nullptr) { - return Status::Error("Ignore notification in unknown chat"); + return Status::Error(406, "Ignore notification in unknown chat"); } bool is_new_pinned = is_pinned && message_id.is_valid() && message_id.get() > d->max_notification_message_id.get(); @@ -18308,7 +18309,7 @@ Result MessagesManager::get_messag 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 Status::Error("Ignore notification about known secret message"); + return Status::Error(406, "Ignore notification about known secret message"); } } diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index adbd52fd..a3804f9d 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -2551,6 +2551,10 @@ void NotificationManager::process_push_notification(string payload, Promiseget_my_id()) { auto status = process_push_notification_payload(payload); if (status.is_error()) { + if (status.code() == 406) { + return promise.set_error(std::move(status)); + } + LOG(ERROR) << "Receive error " << status << ", while parsing push payload " << payload; return promise.set_error(Status::Error(400, status.message())); } @@ -3120,6 +3124,9 @@ Status NotificationManager::process_message_push_notification(DialogId dialog_id if (logevent_id != 0) { binlog_erase(G()->td_db()->get_binlog(), logevent_id); } + if (r_info.error().code() == 406) { + return r_info.move_as_error(); + } return Status::OK(); } @@ -3130,8 +3137,9 @@ Status NotificationManager::process_message_push_notification(DialogId dialog_id VLOG(notifications) << "Skip notification in secret " << dialog_id; // TODO support secret chat notifications // main problem: there is no message_id yet + // also don't forget to delete newSecretChat notification CHECK(logevent_id == 0); - return Status::OK(); + return Status::Error(406, "Secret chat push notifications are unsupported"); } CHECK(random_id == 0);