Improve MessageReplyHeader field names.

This commit is contained in:
levlam 2023-06-05 19:45:05 +03:00
parent 2467633a74
commit e7ca635db9
3 changed files with 33 additions and 33 deletions

View File

@ -21,42 +21,42 @@ MessageReplyHeader::MessageReplyHeader(tl_object_ptr<telegram_api::MessageReplyH
}
auto reply_header = telegram_api::move_object_as<telegram_api::messageReplyHeader>(reply_header_ptr);
if (reply_header->reply_to_scheduled_) {
reply_to_message_id = MessageId(ScheduledServerMessageId(reply_header->reply_to_msg_id_), date);
reply_to_message_id_ = MessageId(ScheduledServerMessageId(reply_header->reply_to_msg_id_), date);
if (message_id.is_scheduled()) {
auto reply_to_peer_id = std::move(reply_header->reply_to_peer_id_);
if (reply_to_peer_id != nullptr) {
reply_in_dialog_id = DialogId(reply_to_peer_id);
LOG(ERROR) << "Receive reply to " << FullMessageId{reply_in_dialog_id, reply_to_message_id} << " in "
reply_in_dialog_id_ = DialogId(reply_to_peer_id);
LOG(ERROR) << "Receive reply to " << FullMessageId{reply_in_dialog_id_, reply_to_message_id_} << " in "
<< FullMessageId{dialog_id, message_id};
reply_to_message_id = MessageId();
reply_in_dialog_id = DialogId();
reply_to_message_id_ = MessageId();
reply_in_dialog_id_ = DialogId();
}
} else {
LOG(ERROR) << "Receive reply to " << reply_to_message_id << " in " << FullMessageId{dialog_id, message_id};
reply_to_message_id = MessageId();
LOG(ERROR) << "Receive reply to " << reply_to_message_id_ << " in " << FullMessageId{dialog_id, message_id};
reply_to_message_id_ = MessageId();
}
} else {
reply_to_message_id = MessageId(ServerMessageId(reply_header->reply_to_msg_id_));
reply_to_message_id_ = MessageId(ServerMessageId(reply_header->reply_to_msg_id_));
auto reply_to_peer_id = std::move(reply_header->reply_to_peer_id_);
if (reply_to_peer_id != nullptr) {
reply_in_dialog_id = DialogId(reply_to_peer_id);
if (!reply_in_dialog_id.is_valid()) {
reply_in_dialog_id_ = DialogId(reply_to_peer_id);
if (!reply_in_dialog_id_.is_valid()) {
LOG(ERROR) << "Receive reply in invalid " << to_string(reply_to_peer_id);
reply_to_message_id = MessageId();
reply_in_dialog_id = DialogId();
reply_to_message_id_ = MessageId();
reply_in_dialog_id_ = DialogId();
}
if (reply_in_dialog_id == dialog_id) {
reply_in_dialog_id = DialogId(); // just in case
if (reply_in_dialog_id_ == dialog_id) {
reply_in_dialog_id_ = DialogId(); // just in case
}
}
if (reply_to_message_id.is_valid() && !message_id.is_scheduled() && !reply_in_dialog_id.is_valid() &&
if (reply_to_message_id_.is_valid() && !message_id.is_scheduled() && !reply_in_dialog_id_.is_valid() &&
can_have_thread) {
if ((reply_header->flags_ & telegram_api::messageReplyHeader::REPLY_TO_TOP_ID_MASK) != 0) {
top_thread_message_id = MessageId(ServerMessageId(reply_header->reply_to_top_id_));
top_thread_message_id_ = MessageId(ServerMessageId(reply_header->reply_to_top_id_));
} else {
top_thread_message_id = reply_to_message_id;
top_thread_message_id_ = reply_to_message_id_;
}
is_topic_message = reply_header->forum_topic_;
is_topic_message_ = reply_header->forum_topic_;
}
}
}

View File

@ -15,10 +15,10 @@
namespace td {
struct MessageReplyHeader {
MessageId reply_to_message_id;
DialogId reply_in_dialog_id;
MessageId top_thread_message_id;
bool is_topic_message = false;
MessageId reply_to_message_id_;
DialogId reply_in_dialog_id_;
MessageId top_thread_message_id_;
bool is_topic_message_ = false;
MessageReplyHeader() = default;

View File

@ -14082,14 +14082,14 @@ void MessagesManager::on_get_secret_message(SecretChatId secret_chat_id, UserId
int32 flags = MESSAGE_FLAG_HAS_UNREAD_CONTENT | MESSAGE_FLAG_HAS_FROM_ID;
if ((message->flags_ & secret_api::decryptedMessage::REPLY_TO_RANDOM_ID_MASK) != 0) {
message_info.reply_header.reply_to_message_id =
message_info.reply_header.reply_to_message_id_ =
get_message_id_by_random_id(d, message->reply_to_random_id_, "on_get_secret_message");
if (!message_info.reply_header.reply_to_message_id.is_valid()) {
if (!message_info.reply_header.reply_to_message_id_.is_valid()) {
auto dialog_it = pending_secret_message_ids_.find(message_info.dialog_id);
if (dialog_it != pending_secret_message_ids_.end()) {
auto message_it = dialog_it->second.find(message->reply_to_random_id_);
if (message_it != dialog_it->second.end()) {
message_info.reply_header.reply_to_message_id = message_it->second;
message_info.reply_header.reply_to_message_id_ = message_it->second;
}
}
}
@ -14384,10 +14384,10 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message(
message_info.reply_header = MessageReplyHeader(std::move(message->reply_to_), message_info.dialog_id,
message_info.message_id, message_info.date, can_have_thread);
message_info.content = get_action_message_content(td_, std::move(message->action_), message_info.dialog_id,
message_info.reply_header.reply_in_dialog_id,
message_info.reply_header.reply_to_message_id);
message_info.reply_header.reply_in_dialog_id = DialogId();
message_info.reply_header.reply_to_message_id = MessageId();
message_info.reply_header.reply_in_dialog_id_,
message_info.reply_header.reply_to_message_id_);
message_info.reply_header.reply_in_dialog_id_ = DialogId();
message_info.reply_header.reply_to_message_id_ = MessageId();
break;
}
default:
@ -14500,10 +14500,10 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
date = 1;
}
MessageId reply_to_message_id = message_info.reply_header.reply_to_message_id;
DialogId reply_in_dialog_id = message_info.reply_header.reply_in_dialog_id;
MessageId top_thread_message_id = message_info.reply_header.top_thread_message_id;
bool is_topic_message = message_info.reply_header.is_topic_message;
MessageId reply_to_message_id = message_info.reply_header.reply_to_message_id_;
DialogId reply_in_dialog_id = message_info.reply_header.reply_in_dialog_id_;
MessageId top_thread_message_id = message_info.reply_header.top_thread_message_id_;
bool is_topic_message = message_info.reply_header.is_topic_message_;
fix_server_reply_to_message_id(dialog_id, message_id, reply_in_dialog_id, reply_to_message_id);
fix_server_reply_to_message_id(dialog_id, message_id, reply_in_dialog_id, top_thread_message_id);