Improve logging.

GitOrigin-RevId: f6535e18bc2e3b65a1def9b787ee5902ff16e5e9
This commit is contained in:
levlam 2019-09-04 20:49:24 +03:00
parent 2a717e7cea
commit 4d827dbc78
2 changed files with 7 additions and 3 deletions

View File

@ -9485,6 +9485,7 @@ void MessagesManager::on_send_secret_message_success(int64 random_id, MessageId
void MessagesManager::delete_secret_messages(SecretChatId secret_chat_id, std::vector<int64> random_ids,
Promise<> promise) {
LOG(INFO) << "Delete messages with random_ids " << random_ids << " in " << secret_chat_id;
promise.set_value(Unit()); // TODO: set after event is saved
DialogId dialog_id(secret_chat_id);
Dialog *d = get_dialog_force(dialog_id);
@ -9497,12 +9498,15 @@ void MessagesManager::delete_secret_messages(SecretChatId secret_chat_id, std::v
for (auto &random_id : random_ids) {
auto message_id = get_message_id_by_random_id(d, random_id, "delete_secret_messages");
if (!message_id.is_valid()) {
LOG(INFO) << "Can't find message with random_id " << random_id;
continue;
}
const Message *m = get_message(d, message_id);
CHECK(m != nullptr);
if (!is_service_message_content(m->content->get_type())) {
to_delete_message_ids.push_back(message_id);
} else {
LOG(INFO) << "Skip deletion of service " << message_id;
}
}
delete_dialog_messages_from_updates(dialog_id, to_delete_message_ids);

View File

@ -1322,14 +1322,14 @@ Status SecretChatActor::do_inbound_message_decrypted(unique_ptr<logevent::Inboun
case secret_api::decryptedMessageActionDeleteMessages::ID:
// Corresponding logevent won't be deleted before promise returned by add_changes is set.
context_->on_delete_messages(
std::move(static_cast<secret_api::decryptedMessageActionDeleteMessages &>(*action).random_ids_),
static_cast<const secret_api::decryptedMessageActionDeleteMessages &>(*action).random_ids_,
std::move(save_message_finish));
break;
case secret_api::decryptedMessageActionFlushHistory::ID:
context_->on_flush_history(MessageId(ServerMessageId(message->message_id)), std::move(save_message_finish));
break;
case secret_api::decryptedMessageActionReadMessages::ID: {
auto &random_ids = static_cast<secret_api::decryptedMessageActionReadMessages &>(*action).random_ids_;
const auto &random_ids = static_cast<const secret_api::decryptedMessageActionReadMessages &>(*action).random_ids_;
if (random_ids.size() == 1) {
context_->on_read_message(random_ids[0], std::move(save_message_finish));
} else { // probably never happens
@ -1349,7 +1349,7 @@ Status SecretChatActor::do_inbound_message_decrypted(unique_ptr<logevent::Inboun
break;
case secret_api::decryptedMessageActionSetMessageTTL::ID:
context_->on_set_ttl(get_user_id(), MessageId(ServerMessageId(message->message_id)), message->date,
static_cast<secret_api::decryptedMessageActionSetMessageTTL &>(*action).ttl_seconds_,
static_cast<const secret_api::decryptedMessageActionSetMessageTTL &>(*action).ttl_seconds_,
decrypted_message_service->random_id_, std::move(save_message_finish));
break;
default: