Improve RepliedMessageInfo::get_reply_message_full_id.
This commit is contained in:
parent
c886e4f3c8
commit
08359b46fc
@ -6012,7 +6012,7 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
|
||||
break;
|
||||
}
|
||||
auto action = move_tl_object_as<telegram_api::messageActionPaymentSent>(action_ptr);
|
||||
auto message_full_id = replied_message_info.get_reply_message_full_id(DialogId());
|
||||
auto message_full_id = replied_message_info.get_reply_message_full_id(DialogId(), true);
|
||||
if (!message_full_id.get_message_id().is_valid()) {
|
||||
if (message_full_id.get_message_id() != MessageId()) {
|
||||
LOG(ERROR) << "Receive successful payment message with " << message_full_id << " in " << owner_dialog_id;
|
||||
|
@ -14786,7 +14786,7 @@ MessageFullId MessagesManager::on_get_message(MessageInfo &&message_info, const
|
||||
update_message(d, old_message.get(), std::move(new_message), false);
|
||||
new_message = std::move(old_message);
|
||||
|
||||
auto reply_message_full_id = new_message->replied_message_info.get_reply_message_full_id(dialog_id);
|
||||
auto reply_message_full_id = new_message->replied_message_info.get_reply_message_full_id(dialog_id, false);
|
||||
auto reply_message_id = reply_message_full_id.get_message_id();
|
||||
if (reply_message_id.is_valid() && reply_message_id.is_yet_unsent()) {
|
||||
set_message_reply(d, new_message.get(), MessageInputReplyTo(), false);
|
||||
@ -17725,11 +17725,11 @@ MessageFullId MessagesManager::get_replied_message_id(DialogId dialog_id, const
|
||||
CHECK(m->replied_message_info.is_empty());
|
||||
return message_full_id;
|
||||
}
|
||||
auto reply_message_full_id = m->replied_message_info.get_reply_message_full_id(dialog_id);
|
||||
auto reply_message_full_id = m->replied_message_info.get_reply_message_full_id(dialog_id, true);
|
||||
if (reply_message_full_id.get_message_id() != MessageId()) {
|
||||
return reply_message_full_id;
|
||||
}
|
||||
if (m->top_thread_message_id.is_valid() && is_service_message_content(m->content->get_type())) {
|
||||
if (m->top_thread_message_id.is_valid()) {
|
||||
return {dialog_id, m->top_thread_message_id};
|
||||
}
|
||||
return {};
|
||||
@ -27233,7 +27233,7 @@ void MessagesManager::update_message_max_reply_media_timestamp(const Dialog *d,
|
||||
}
|
||||
|
||||
auto new_max_reply_media_timestamp = -1;
|
||||
auto reply_message_full_id = m->replied_message_info.get_reply_message_full_id(d->dialog_id);
|
||||
auto reply_message_full_id = m->replied_message_info.get_reply_message_full_id(d->dialog_id, false);
|
||||
auto reply_message_id = reply_message_full_id.get_message_id();
|
||||
if (reply_message_id.is_valid() && !reply_message_id.is_yet_unsent()) {
|
||||
const auto *reply_d =
|
||||
@ -27323,7 +27323,7 @@ void MessagesManager::update_message_max_reply_media_timestamp_in_replied_messag
|
||||
Dialog *d = get_dialog(replied_dialog_id);
|
||||
auto m = get_message(d, replied_message_full_id.get_message_id());
|
||||
CHECK(m != nullptr);
|
||||
CHECK(m->replied_message_info.get_reply_message_full_id(replied_dialog_id) == message_full_id);
|
||||
CHECK(m->replied_message_info.get_reply_message_full_id(replied_dialog_id, false) == message_full_id);
|
||||
update_message_max_reply_media_timestamp(d, m, true);
|
||||
}
|
||||
}
|
||||
@ -27350,7 +27350,7 @@ bool MessagesManager::can_register_message_reply(const Message *m) const {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return false;
|
||||
}
|
||||
auto reply_message_full_id = m->replied_message_info.get_reply_message_full_id(DialogId());
|
||||
auto reply_message_full_id = m->replied_message_info.get_reply_message_full_id(DialogId(), false);
|
||||
auto reply_message_id = reply_message_full_id.get_message_id();
|
||||
if (reply_message_id.is_valid() && !reply_message_id.is_yet_unsent()) {
|
||||
return true;
|
||||
@ -27376,7 +27376,7 @@ void MessagesManager::register_message_reply(DialogId dialog_id, const Message *
|
||||
.second;
|
||||
CHECK(is_inserted);
|
||||
} else {
|
||||
auto message_full_id = m->replied_message_info.get_reply_message_full_id(dialog_id);
|
||||
auto message_full_id = m->replied_message_info.get_reply_message_full_id(dialog_id, false);
|
||||
LOG(INFO) << "Register " << m->message_id << " in " << dialog_id << " as reply to " << message_full_id;
|
||||
bool is_inserted =
|
||||
message_to_replied_media_timestamp_messages_[message_full_id].insert({dialog_id, m->message_id}).second;
|
||||
@ -27397,7 +27397,7 @@ void MessagesManager::reregister_message_reply(DialogId dialog_id, const Message
|
||||
was_registered =
|
||||
it != story_to_replied_media_timestamp_messages_.end() && it->second.count({dialog_id, m->message_id}) > 0;
|
||||
} else {
|
||||
auto message_full_id = m->replied_message_info.get_reply_message_full_id(dialog_id);
|
||||
auto message_full_id = m->replied_message_info.get_reply_message_full_id(dialog_id, false);
|
||||
auto it = message_to_replied_media_timestamp_messages_.find(message_full_id);
|
||||
was_registered =
|
||||
it != message_to_replied_media_timestamp_messages_.end() && it->second.count({dialog_id, m->message_id}) > 0;
|
||||
@ -27436,7 +27436,7 @@ void MessagesManager::unregister_message_reply(DialogId dialog_id, const Message
|
||||
}
|
||||
}
|
||||
} else {
|
||||
auto message_full_id = m->replied_message_info.get_reply_message_full_id(dialog_id);
|
||||
auto message_full_id = m->replied_message_info.get_reply_message_full_id(dialog_id, false);
|
||||
auto it = message_to_replied_media_timestamp_messages_.find(message_full_id);
|
||||
if (it == message_to_replied_media_timestamp_messages_.end()) {
|
||||
return;
|
||||
@ -36032,7 +36032,7 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr
|
||||
LOG(INFO) << "Update replied message of " << MessageFullId{dialog_id, message_id} << " from "
|
||||
<< old_message->replied_message_info << " to " << new_message->replied_message_info;
|
||||
auto is_reply_to_deleted_message = [&](const RepliedMessageInfo &replied_message_info) {
|
||||
auto reply_message_full_id = replied_message_info.get_reply_message_full_id(dialog_id);
|
||||
auto reply_message_full_id = replied_message_info.get_reply_message_full_id(dialog_id, false);
|
||||
auto *d = get_dialog(reply_message_full_id.get_dialog_id());
|
||||
if (d == nullptr) {
|
||||
return false;
|
||||
|
@ -370,8 +370,11 @@ MessageId RepliedMessageInfo::get_same_chat_reply_to_message_id() const {
|
||||
return dialog_id_ == DialogId() && origin_.is_empty() ? message_id_ : MessageId();
|
||||
}
|
||||
|
||||
MessageFullId RepliedMessageInfo::get_reply_message_full_id(DialogId owner_dialog_id) const {
|
||||
if (!message_id_.is_valid() && !message_id_.is_valid_scheduled()) {
|
||||
MessageFullId RepliedMessageInfo::get_reply_message_full_id(DialogId owner_dialog_id, bool ignore_external) const {
|
||||
if (message_id_ == MessageId()) {
|
||||
return {};
|
||||
}
|
||||
if (ignore_external && !origin_.is_empty()) {
|
||||
return {};
|
||||
}
|
||||
return {dialog_id_.is_valid() ? dialog_id_ : owner_dialog_id, message_id_};
|
||||
|
@ -100,7 +100,7 @@ class RepliedMessageInfo {
|
||||
|
||||
MessageId get_same_chat_reply_to_message_id() const;
|
||||
|
||||
MessageFullId get_reply_message_full_id(DialogId owner_dialog_id) const;
|
||||
MessageFullId get_reply_message_full_id(DialogId owner_dialog_id, bool ignore_external) const;
|
||||
|
||||
void register_content(Td *td) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user