Move other reply_to_message_id checks to ReplyHeader parsing.
This commit is contained in:
parent
bd923a36eb
commit
e4ffed5752
@ -48,13 +48,19 @@ MessageReplyHeader::MessageReplyHeader(Td *td, tl_object_ptr<telegram_api::Messa
|
||||
|
||||
replied_message_info_ = RepliedMessageInfo(td, std::move(reply_header), dialog_id, message_id, date);
|
||||
|
||||
if (!message_id.is_scheduled() && can_have_thread && !top_thread_message_id_.is_valid()) {
|
||||
auto same_chat_reply_to_message_id = replied_message_info_.get_same_chat_reply_to_message_id();
|
||||
if (same_chat_reply_to_message_id.is_valid()) {
|
||||
CHECK(same_chat_reply_to_message_id.is_server());
|
||||
top_thread_message_id_ = same_chat_reply_to_message_id;
|
||||
} else {
|
||||
is_topic_message_ = false;
|
||||
if (!message_id.is_scheduled() && can_have_thread) {
|
||||
if (!top_thread_message_id_.is_valid()) {
|
||||
auto same_chat_reply_to_message_id = replied_message_info_.get_same_chat_reply_to_message_id();
|
||||
if (same_chat_reply_to_message_id.is_valid()) {
|
||||
CHECK(same_chat_reply_to_message_id.is_server());
|
||||
top_thread_message_id_ = same_chat_reply_to_message_id;
|
||||
} else {
|
||||
is_topic_message_ = false;
|
||||
}
|
||||
}
|
||||
if (top_thread_message_id_ >= message_id) {
|
||||
LOG(ERROR) << "Receive top thread " << top_thread_message_id_ << " in " << message_id << " in " << dialog_id;
|
||||
top_thread_message_id_ = MessageId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14448,9 +14448,6 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
|
||||
DialogId reply_in_dialog_id = reply_message_full_id.get_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);
|
||||
|
||||
auto reply_to_story_full_id = message_info.reply_header.story_full_id_;
|
||||
if (reply_to_story_full_id != StoryFullId() &&
|
||||
(dialog_type != DialogType::User || (reply_to_story_full_id.get_dialog_id() != my_dialog_id &&
|
||||
@ -24541,30 +24538,6 @@ MessageInputReplyTo MessagesManager::get_message_input_reply_to(const Message *m
|
||||
return m->input_reply_to;
|
||||
}
|
||||
|
||||
void MessagesManager::fix_server_reply_to_message_id(DialogId dialog_id, MessageId message_id,
|
||||
DialogId reply_in_dialog_id,
|
||||
MessageId &reply_to_message_id) const {
|
||||
if (!reply_to_message_id.is_valid()) {
|
||||
if (reply_to_message_id.is_valid_scheduled()) {
|
||||
CHECK(message_id.is_scheduled());
|
||||
CHECK(reply_in_dialog_id == DialogId());
|
||||
if (message_id == reply_to_message_id) {
|
||||
LOG(ERROR) << "Receive reply to " << reply_to_message_id << " for " << message_id << " in " << dialog_id;
|
||||
reply_to_message_id = MessageId();
|
||||
}
|
||||
return;
|
||||
}
|
||||
CHECK(reply_to_message_id == MessageId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!message_id.is_scheduled() && !reply_in_dialog_id.is_valid() &&
|
||||
((reply_to_message_id > message_id && !has_qts_messages(dialog_id)) || reply_to_message_id == message_id)) {
|
||||
LOG(ERROR) << "Receive reply to wrong " << reply_to_message_id << " in " << message_id << " in " << dialog_id;
|
||||
reply_to_message_id = MessageId();
|
||||
}
|
||||
}
|
||||
|
||||
vector<FileId> MessagesManager::get_message_file_ids(const Message *m) const {
|
||||
CHECK(m != nullptr);
|
||||
return get_message_content_file_ids(m->content.get(), td_);
|
||||
@ -26221,21 +26194,6 @@ void MessagesManager::do_send_inline_query_result_message(DialogId dialog_id, Me
|
||||
get_message_schedule_date(m), random_id, query_id, result_id);
|
||||
}
|
||||
|
||||
bool MessagesManager::has_qts_messages(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
case DialogType::Chat:
|
||||
return td_->option_manager_->get_option_integer("session_count") > 1;
|
||||
case DialogType::Channel:
|
||||
case DialogType::SecretChat:
|
||||
return false;
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool MessagesManager::can_edit_message(DialogId dialog_id, const Message *m, bool is_editing,
|
||||
bool only_reply_markup) const {
|
||||
if (m == nullptr) {
|
||||
|
@ -1816,8 +1816,6 @@ class MessagesManager final : public Actor {
|
||||
|
||||
bool can_edit_message(DialogId dialog_id, const Message *m, bool is_editing, bool only_reply_markup = false) const;
|
||||
|
||||
bool has_qts_messages(DialogId dialog_id) const;
|
||||
|
||||
bool can_report_dialog(DialogId dialog_id) const;
|
||||
|
||||
Status can_pin_messages(DialogId dialog_id) const;
|
||||
@ -1846,9 +1844,6 @@ class MessagesManager final : public Actor {
|
||||
|
||||
static MessageInputReplyTo get_message_input_reply_to(const Message *m);
|
||||
|
||||
void fix_server_reply_to_message_id(DialogId dialog_id, MessageId message_id, DialogId reply_in_dialog_id,
|
||||
MessageId &reply_to_message_id) const;
|
||||
|
||||
bool can_set_game_score(DialogId dialog_id, const Message *m) const;
|
||||
|
||||
void add_postponed_channel_update(DialogId dialog_id, tl_object_ptr<telegram_api::Update> &&update, int32 new_pts,
|
||||
|
@ -7,21 +7,38 @@
|
||||
#include "td/telegram/RepliedMessageInfo.h"
|
||||
|
||||
#include "td/telegram/MessageFullId.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/ScheduledServerMessageId.h"
|
||||
#include "td/telegram/ServerMessageId.h"
|
||||
#include "td/telegram/StoryId.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
static bool has_qts_messages(const Td *td, DialogId dialog_id) {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
case DialogType::Chat:
|
||||
return td->option_manager_->get_option_integer("session_count") > 1;
|
||||
case DialogType::Channel:
|
||||
case DialogType::SecretChat:
|
||||
return false;
|
||||
case DialogType::None:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messageReplyHeader> &&reply_header,
|
||||
DialogId dialog_id, MessageId message_id, int32 date) {
|
||||
CHECK(reply_header != nullptr);
|
||||
if (reply_header->reply_to_scheduled_) {
|
||||
message_id_ = MessageId(ScheduledServerMessageId(reply_header->reply_to_msg_id_), date);
|
||||
if (message_id.is_scheduled()) {
|
||||
if (message_id.is_valid_scheduled()) {
|
||||
auto reply_to_peer_id = std::move(reply_header->reply_to_peer_id_);
|
||||
if (reply_to_peer_id != nullptr) {
|
||||
dialog_id_ = DialogId(reply_to_peer_id);
|
||||
@ -30,6 +47,10 @@ RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messa
|
||||
message_id_ = MessageId();
|
||||
dialog_id_ = DialogId();
|
||||
}
|
||||
if (message_id == message_id_) {
|
||||
LOG(ERROR) << "Receive reply to " << message_id_ << " in " << MessageFullId{dialog_id, message_id};
|
||||
message_id_ = MessageId();
|
||||
}
|
||||
} else {
|
||||
LOG(ERROR) << "Receive reply to " << message_id_ << " in " << MessageFullId{dialog_id, message_id};
|
||||
message_id_ = MessageId();
|
||||
@ -58,6 +79,10 @@ RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messa
|
||||
LOG(ERROR) << "Receive " << to_string(reply_header) << " in " << MessageFullId{dialog_id, message_id};
|
||||
message_id_ = MessageId();
|
||||
dialog_id_ = DialogId();
|
||||
} else if (!message_id.is_scheduled() && !dialog_id_.is_valid() &&
|
||||
((message_id_ > message_id && !has_qts_messages(td, dialog_id)) || message_id_ == message_id)) {
|
||||
LOG(ERROR) << "Receive reply to " << message_id_ << " in " << MessageFullId{dialog_id, message_id};
|
||||
message_id_ = MessageId();
|
||||
}
|
||||
} else if (reply_header->reply_to_peer_id_ != nullptr) {
|
||||
LOG(ERROR) << "Receive " << to_string(reply_header) << " in " << MessageFullId{dialog_id, message_id};
|
||||
|
Loading…
Reference in New Issue
Block a user