From f1a23b9256e914ed7ce3afd13ddd8c89cac26409 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 2 Aug 2020 01:21:43 +0300 Subject: [PATCH] Remove qts from logevent::InboundSecretMessage. GitOrigin-RevId: ae90e87e3bd0291e78c56cfea161724882d76f1d --- td/telegram/SecretChatsManager.cpp | 7 +++---- td/telegram/logevent/SecretChatEvent.h | 21 ++++++++++++--------- test/secret.cpp | 1 - 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/td/telegram/SecretChatsManager.cpp b/td/telegram/SecretChatsManager.cpp index 67b1ac642..41695c6a2 100644 --- a/td/telegram/SecretChatsManager.cpp +++ b/td/telegram/SecretChatsManager.cpp @@ -261,7 +261,7 @@ void SecretChatsManager::on_update_message(tl_object_ptr(); - event->qts = qts; + event->qts_ack = add_qts(qts); downcast_call(*update->message_, [&](auto &x) { event->chat_id = x.chat_id_; event->date = x.date_; @@ -324,14 +324,13 @@ void SecretChatsManager::binlog_replay_finish() { } void SecretChatsManager::replay_inbound_message(unique_ptr message) { - LOG(INFO) << "Replay inbound secret message in chat " << message->chat_id << " with qts " << message->qts; + LOG(INFO) << "Replay inbound secret message in chat " << message->chat_id; auto actor = get_chat_actor(message->chat_id); send_closure_later(actor, &SecretChatActor::replay_inbound_message, std::move(message)); } void SecretChatsManager::add_inbound_message(unique_ptr message) { - LOG(INFO) << "Process inbound secret message in chat " << message->chat_id << " with qts " << message->qts; - message->qts_ack = add_qts(message->qts); + LOG(INFO) << "Process inbound secret message in chat " << message->chat_id; auto actor = get_chat_actor(message->chat_id); send_closure(actor, &SecretChatActor::add_inbound_message, std::move(message)); diff --git a/td/telegram/logevent/SecretChatEvent.h b/td/telegram/logevent/SecretChatEvent.h index e0c22e481..6c9e11c50 100644 --- a/td/telegram/logevent/SecretChatEvent.h +++ b/td/telegram/logevent/SecretChatEvent.h @@ -206,7 +206,6 @@ inline StringBuilder &operator<<(StringBuilder &sb, const EncryptedFileLocation class InboundSecretMessage : public SecretChatLogEventBase { public: static constexpr Type type = SecretChatEvent::Type::InboundSecretMessage; - int32 qts = 0; int32 chat_id = 0; int32 date = 0; @@ -240,9 +239,9 @@ class InboundSecretMessage : public SecretChatLogEventBase BEGIN_STORE_FLAGS(); STORE_FLAG(has_encrypted_file); STORE_FLAG(is_pending); + STORE_FLAG(true); END_STORE_FLAGS(); - store(qts, storer); store(chat_id, storer); store(date, storer); // skip encrypted_message @@ -265,12 +264,17 @@ class InboundSecretMessage : public SecretChatLogEventBase void parse(ParserT &parser) { using td::parse; + bool no_qts; BEGIN_PARSE_FLAGS(); PARSE_FLAG(has_encrypted_file); PARSE_FLAG(is_pending); + PARSE_FLAG(no_qts); END_PARSE_FLAGS(); - parse(qts, parser); + if (!no_qts) { + int32 legacy_qts; + parse(legacy_qts, parser); + } parse(chat_id, parser); parse(date, parser); // skip encrypted_message @@ -292,12 +296,11 @@ class InboundSecretMessage : public SecretChatLogEventBase } StringBuilder &print(StringBuilder &sb) const override { - return sb << "[Logevent InboundSecretMessage " << tag("id", logevent_id()) << tag("qts", qts) - << tag("chat_id", chat_id) << tag("date", date) << tag("auth_key_id", format::as_hex(auth_key_id)) - << tag("message_id", message_id) << tag("my_in_seq_no", my_in_seq_no) - << tag("my_out_seq_no", my_out_seq_no) << tag("his_in_seq_no", his_in_seq_no) - << tag("message", to_string(decrypted_message_layer)) << tag("is_pending", is_pending) - << format::cond(has_encrypted_file, tag("file", file)) << "]"; + return sb << "[Logevent InboundSecretMessage " << tag("id", logevent_id()) << tag("chat_id", chat_id) + << tag("date", date) << tag("auth_key_id", format::as_hex(auth_key_id)) << tag("message_id", message_id) + << tag("my_in_seq_no", my_in_seq_no) << tag("my_out_seq_no", my_out_seq_no) + << tag("his_in_seq_no", his_in_seq_no) << tag("message", to_string(decrypted_message_layer)) + << tag("is_pending", is_pending) << format::cond(has_encrypted_file, tag("file", file)) << "]"; } }; diff --git a/test/secret.cpp b/test/secret.cpp index a5cf8f61c..6bb068bce 100644 --- a/test/secret.cpp +++ b/test/secret.cpp @@ -588,7 +588,6 @@ class Master : public Actor { void add_inbound_message(int32 chat_id, BufferSlice data, uint64 crc) { CHECK(crc64(data.as_slice()) == crc); auto event = make_unique(); - event->qts = 0; event->chat_id = chat_id; event->date = 0; event->encrypted_message = std::move(data);