Improve MessageReplyInfo field names.

This commit is contained in:
levlam 2022-11-21 18:35:28 +03:00
parent 44df11cfcf
commit f94e27fe12
4 changed files with 137 additions and 136 deletions

View File

@ -27,31 +27,31 @@ MessageReplyInfo::MessageReplyInfo(Td *td, tl_object_ptr<telegram_api::messageRe
return;
}
if (is_bot || reply_info->channel_id_ == 777) {
is_dropped = true;
is_dropped_ = true;
return;
}
reply_count = reply_info->replies_;
pts = reply_info->replies_pts_;
reply_count_ = reply_info->replies_;
pts_ = reply_info->replies_pts_;
is_comment = reply_info->comments_;
is_comment_ = reply_info->comments_;
if (is_comment) {
channel_id = ChannelId(reply_info->channel_id_);
if (!channel_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << channel_id;
channel_id = ChannelId();
is_comment = false;
if (is_comment_) {
channel_id_ = ChannelId(reply_info->channel_id_);
if (!channel_id_.is_valid()) {
LOG(ERROR) << "Receive invalid " << channel_id_;
channel_id_ = ChannelId();
is_comment_ = false;
}
}
if (is_comment) {
if (is_comment_) {
for (const auto &peer : reply_info->recent_repliers_) {
DialogId dialog_id(peer);
if (!dialog_id.is_valid()) {
LOG(ERROR) << "Receive " << dialog_id << " as a recent replier";
continue;
}
if (td::contains(recent_replier_dialog_ids, dialog_id)) {
if (td::contains(recent_replier_dialog_ids_, dialog_id)) {
LOG(ERROR) << "Receive duplicate " << dialog_id << " as a recent replier";
continue;
}
@ -70,28 +70,28 @@ MessageReplyInfo::MessageReplyInfo(Td *td, tl_object_ptr<telegram_api::messageRe
LOG(ERROR) << "Receive unknown replied " << replier_channel_id;
continue;
}
replier_min_channels.emplace_back(replier_channel_id, *min_channel);
replier_min_channels_.emplace_back(replier_channel_id, *min_channel);
} else {
LOG(ERROR) << "Receive unknown replied " << dialog_id;
continue;
}
}
recent_replier_dialog_ids.push_back(dialog_id);
if (recent_replier_dialog_ids.size() == MAX_RECENT_REPLIERS) {
recent_replier_dialog_ids_.push_back(dialog_id);
if (recent_replier_dialog_ids_.size() == MAX_RECENT_REPLIERS) {
break;
}
}
}
if ((reply_info->flags_ & telegram_api::messageReplies::MAX_ID_MASK) != 0 &&
ServerMessageId(reply_info->max_id_).is_valid()) {
max_message_id = MessageId(ServerMessageId(reply_info->max_id_));
max_message_id_ = MessageId(ServerMessageId(reply_info->max_id_));
}
if ((reply_info->flags_ & telegram_api::messageReplies::READ_MAX_ID_MASK) != 0 &&
ServerMessageId(reply_info->read_max_id_).is_valid()) {
last_read_inbox_message_id = MessageId(ServerMessageId(reply_info->read_max_id_));
last_read_inbox_message_id_ = MessageId(ServerMessageId(reply_info->read_max_id_));
}
if (last_read_inbox_message_id > max_message_id) { // possible if last thread message was deleted after it was read
max_message_id = last_read_inbox_message_id;
if (last_read_inbox_message_id_ > max_message_id_) { // possible if last thread message was deleted after it was read
max_message_id_ = last_read_inbox_message_id_;
}
LOG(DEBUG) << "Parsed " << oneline(to_string(reply_info)) << " to " << *this;
}
@ -101,41 +101,41 @@ bool MessageReplyInfo::need_update_to(const MessageReplyInfo &other) const {
// ignore updates to empty reply info, because we will hide the info ourselves
// return true;
}
if (other.pts < pts && !other.was_dropped()) {
if (other.pts_ < pts_ && !other.was_dropped()) {
return false;
}
return reply_count != other.reply_count || recent_replier_dialog_ids != other.recent_replier_dialog_ids ||
replier_min_channels.size() != other.replier_min_channels.size() || is_comment != other.is_comment ||
channel_id != other.channel_id;
return reply_count_ != other.reply_count_ || recent_replier_dialog_ids_ != other.recent_replier_dialog_ids_ ||
replier_min_channels_.size() != other.replier_min_channels_.size() || is_comment_ != other.is_comment_ ||
channel_id_ != other.channel_id_;
}
bool MessageReplyInfo::update_max_message_ids(const MessageReplyInfo &other) {
return update_max_message_ids(other.max_message_id, other.last_read_inbox_message_id,
other.last_read_outbox_message_id);
return update_max_message_ids(other.max_message_id_, other.last_read_inbox_message_id_,
other.last_read_outbox_message_id_);
}
bool MessageReplyInfo::update_max_message_ids(MessageId other_max_message_id,
MessageId other_last_read_inbox_message_id,
MessageId other_last_read_outbox_message_id) {
bool result = false;
if (other_last_read_inbox_message_id > last_read_inbox_message_id) {
last_read_inbox_message_id = other_last_read_inbox_message_id;
if (other_last_read_inbox_message_id > last_read_inbox_message_id_) {
last_read_inbox_message_id_ = other_last_read_inbox_message_id;
result = true;
}
if (other_last_read_outbox_message_id > last_read_outbox_message_id) {
last_read_outbox_message_id = other_last_read_outbox_message_id;
if (other_last_read_outbox_message_id > last_read_outbox_message_id_) {
last_read_outbox_message_id_ = other_last_read_outbox_message_id;
result = true;
}
if (other_max_message_id.is_valid() ||
(!other_last_read_inbox_message_id.is_valid() && !other_last_read_outbox_message_id.is_valid())) {
if (other_max_message_id < last_read_inbox_message_id) {
other_max_message_id = last_read_inbox_message_id;
if (other_max_message_id < last_read_inbox_message_id_) {
other_max_message_id = last_read_inbox_message_id_;
}
if (other_max_message_id < last_read_outbox_message_id) {
other_max_message_id = last_read_outbox_message_id;
if (other_max_message_id < last_read_outbox_message_id_) {
other_max_message_id = last_read_outbox_message_id_;
}
if (other_max_message_id != max_message_id) {
max_message_id = other_max_message_id;
if (other_max_message_id != max_message_id_) {
max_message_id_ = other_max_message_id;
result = true;
}
}
@ -146,44 +146,44 @@ bool MessageReplyInfo::add_reply(DialogId replier_dialog_id, MessageId reply_mes
CHECK(!is_empty());
CHECK(diff == +1 || diff == -1);
if (diff == -1 && reply_count == 0) {
if (diff == -1 && reply_count_ == 0) {
return false;
}
reply_count += diff;
if (is_comment && replier_dialog_id.is_valid()) {
reply_count_ += diff;
if (is_comment_ && replier_dialog_id.is_valid()) {
if (replier_dialog_id.get_type() == DialogType::Channel) {
// the replier_dialog_id is never min, because it is the sender of a message
for (auto it = replier_min_channels.begin(); it != replier_min_channels.end(); ++it) {
for (auto it = replier_min_channels_.begin(); it != replier_min_channels_.end(); ++it) {
if (it->first == replier_dialog_id.get_channel_id()) {
replier_min_channels.erase(it);
replier_min_channels_.erase(it);
break;
}
}
}
td::remove(recent_replier_dialog_ids, replier_dialog_id);
td::remove(recent_replier_dialog_ids_, replier_dialog_id);
if (diff > 0) {
recent_replier_dialog_ids.insert(recent_replier_dialog_ids.begin(), replier_dialog_id);
if (recent_replier_dialog_ids.size() > MAX_RECENT_REPLIERS) {
recent_replier_dialog_ids.pop_back();
recent_replier_dialog_ids_.insert(recent_replier_dialog_ids_.begin(), replier_dialog_id);
if (recent_replier_dialog_ids_.size() > MAX_RECENT_REPLIERS) {
recent_replier_dialog_ids_.pop_back();
}
} else {
auto max_repliers = static_cast<size_t>(reply_count);
if (recent_replier_dialog_ids.size() > max_repliers) {
recent_replier_dialog_ids.resize(max_repliers);
auto max_repliers = static_cast<size_t>(reply_count_);
if (recent_replier_dialog_ids_.size() > max_repliers) {
recent_replier_dialog_ids_.resize(max_repliers);
}
}
}
if (diff > 0 && reply_message_id > max_message_id) {
max_message_id = reply_message_id;
if (diff > 0 && reply_message_id > max_message_id_) {
max_message_id_ = reply_message_id;
}
return true;
}
bool MessageReplyInfo::need_reget(const Td *td) const {
for (auto &dialog_id : recent_replier_dialog_ids) {
for (auto &dialog_id : recent_replier_dialog_ids_) {
if (dialog_id.get_type() != DialogType::User && !td->messages_manager_->have_dialog_info(dialog_id)) {
if (dialog_id.get_type() == DialogType::Channel &&
td->contacts_manager_->have_min_channel(dialog_id.get_channel_id())) {
@ -202,25 +202,25 @@ td_api::object_ptr<td_api::messageReplyInfo> MessageReplyInfo::get_message_reply
}
vector<td_api::object_ptr<td_api::MessageSender>> recent_repliers;
for (auto dialog_id : recent_replier_dialog_ids) {
for (auto dialog_id : recent_replier_dialog_ids_) {
auto recent_replier = get_min_message_sender_object(td, dialog_id, "get_message_reply_info_object");
if (recent_replier != nullptr) {
recent_repliers.push_back(std::move(recent_replier));
}
}
return td_api::make_object<td_api::messageReplyInfo>(reply_count, std::move(recent_repliers),
last_read_inbox_message_id.get(),
last_read_outbox_message_id.get(), max_message_id.get());
return td_api::make_object<td_api::messageReplyInfo>(reply_count_, std::move(recent_repliers),
last_read_inbox_message_id_.get(),
last_read_outbox_message_id_.get(), max_message_id_.get());
}
StringBuilder &operator<<(StringBuilder &string_builder, const MessageReplyInfo &reply_info) {
if (reply_info.is_comment) {
return string_builder << reply_info.reply_count << " comments in " << reply_info.channel_id << " by "
<< reply_info.recent_replier_dialog_ids << " read up to "
<< reply_info.last_read_inbox_message_id << "/" << reply_info.last_read_outbox_message_id;
if (reply_info.is_comment_) {
return string_builder << reply_info.reply_count_ << " comments in " << reply_info.channel_id_ << " by "
<< reply_info.recent_replier_dialog_ids_ << " read up to "
<< reply_info.last_read_inbox_message_id_ << "/" << reply_info.last_read_outbox_message_id_;
} else {
return string_builder << reply_info.reply_count << " replies read up to " << reply_info.last_read_inbox_message_id
<< "/" << reply_info.last_read_outbox_message_id;
return string_builder << reply_info.reply_count_ << " replies read up to " << reply_info.last_read_inbox_message_id_
<< "/" << reply_info.last_read_outbox_message_id_;
}
}

View File

@ -23,16 +23,16 @@ namespace td {
class Td;
struct MessageReplyInfo {
int32 reply_count = -1;
int32 pts = -1;
vector<DialogId> recent_replier_dialog_ids; // comments only
vector<std::pair<ChannelId, MinChannel>> replier_min_channels; // comments only
ChannelId channel_id; // comments only
MessageId max_message_id;
MessageId last_read_inbox_message_id;
MessageId last_read_outbox_message_id;
bool is_comment = false;
bool is_dropped = false;
int32 reply_count_ = -1;
int32 pts_ = -1;
vector<DialogId> recent_replier_dialog_ids_; // comments only
vector<std::pair<ChannelId, MinChannel>> replier_min_channels_; // comments only
ChannelId channel_id_; // comments only
MessageId max_message_id_;
MessageId last_read_inbox_message_id_;
MessageId last_read_outbox_message_id_;
bool is_comment_ = false;
bool is_dropped_ = false;
static constexpr size_t MAX_RECENT_REPLIERS = 3;
@ -41,11 +41,11 @@ struct MessageReplyInfo {
MessageReplyInfo(Td *td, tl_object_ptr<telegram_api::messageReplies> &&reply_info, bool is_bot);
bool is_empty() const {
return reply_count < 0;
return reply_count_ < 0;
}
bool was_dropped() const {
return is_dropped;
return is_dropped_;
}
bool need_update_to(const MessageReplyInfo &other) const;

View File

@ -17,14 +17,14 @@ namespace td {
template <class StorerT>
void MessageReplyInfo::store(StorerT &storer) const {
CHECK(!is_empty());
bool has_recent_replier_dialog_ids = !recent_replier_dialog_ids.empty();
bool has_channel_id = channel_id.is_valid();
bool has_max_message_id = max_message_id.is_valid();
bool has_last_read_inbox_message_id = last_read_inbox_message_id.is_valid();
bool has_last_read_outbox_message_id = last_read_outbox_message_id.is_valid();
bool has_replier_min_channels = !replier_min_channels.empty();
bool has_recent_replier_dialog_ids = !recent_replier_dialog_ids_.empty();
bool has_channel_id = channel_id_.is_valid();
bool has_max_message_id = max_message_id_.is_valid();
bool has_last_read_inbox_message_id = last_read_inbox_message_id_.is_valid();
bool has_last_read_outbox_message_id = last_read_outbox_message_id_.is_valid();
bool has_replier_min_channels = !replier_min_channels_.empty();
BEGIN_STORE_FLAGS();
STORE_FLAG(is_comment);
STORE_FLAG(is_comment_);
STORE_FLAG(has_recent_replier_dialog_ids);
STORE_FLAG(has_channel_id);
STORE_FLAG(has_max_message_id);
@ -32,25 +32,25 @@ void MessageReplyInfo::store(StorerT &storer) const {
STORE_FLAG(has_last_read_outbox_message_id);
STORE_FLAG(has_replier_min_channels);
END_STORE_FLAGS();
td::store(reply_count, storer);
td::store(pts, storer);
td::store(reply_count_, storer);
td::store(pts_, storer);
if (has_recent_replier_dialog_ids) {
td::store(recent_replier_dialog_ids, storer);
td::store(recent_replier_dialog_ids_, storer);
}
if (has_channel_id) {
td::store(channel_id, storer);
td::store(channel_id_, storer);
}
if (has_max_message_id) {
td::store(max_message_id, storer);
td::store(max_message_id_, storer);
}
if (has_last_read_inbox_message_id) {
td::store(last_read_inbox_message_id, storer);
td::store(last_read_inbox_message_id_, storer);
}
if (has_last_read_outbox_message_id) {
td::store(last_read_outbox_message_id, storer);
td::store(last_read_outbox_message_id_, storer);
}
if (has_replier_min_channels) {
td::store(replier_min_channels, storer);
td::store(replier_min_channels_, storer);
}
}
@ -63,7 +63,7 @@ void MessageReplyInfo::parse(ParserT &parser) {
bool has_last_read_outbox_message_id;
bool has_replier_min_channels;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_comment);
PARSE_FLAG(is_comment_);
PARSE_FLAG(has_recent_replier_dialog_ids);
PARSE_FLAG(has_channel_id);
PARSE_FLAG(has_max_message_id);
@ -71,32 +71,33 @@ void MessageReplyInfo::parse(ParserT &parser) {
PARSE_FLAG(has_last_read_outbox_message_id);
PARSE_FLAG(has_replier_min_channels);
END_PARSE_FLAGS();
td::parse(reply_count, parser);
td::parse(pts, parser);
td::parse(reply_count_, parser);
td::parse(pts_, parser);
if (has_recent_replier_dialog_ids) {
td::parse(recent_replier_dialog_ids, parser);
td::parse(recent_replier_dialog_ids_, parser);
}
if (has_channel_id) {
td::parse(channel_id, parser);
td::parse(channel_id_, parser);
}
if (has_max_message_id) {
td::parse(max_message_id, parser);
td::parse(max_message_id_, parser);
}
if (has_last_read_inbox_message_id) {
td::parse(last_read_inbox_message_id, parser);
td::parse(last_read_inbox_message_id_, parser);
}
if (has_last_read_outbox_message_id) {
td::parse(last_read_outbox_message_id, parser);
td::parse(last_read_outbox_message_id_, parser);
}
if (has_replier_min_channels) {
td::parse(replier_min_channels, parser);
td::parse(replier_min_channels_, parser);
}
if (channel_id.get() == 777) {
if (channel_id_.get() == 777) {
*this = MessageReplyInfo();
is_dropped_ = true;
}
if (recent_replier_dialog_ids.size() > MAX_RECENT_REPLIERS) {
recent_replier_dialog_ids.resize(MAX_RECENT_REPLIERS);
if (recent_replier_dialog_ids_.size() > MAX_RECENT_REPLIERS) {
recent_replier_dialog_ids_.resize(MAX_RECENT_REPLIERS);
}
}

View File

@ -7089,7 +7089,7 @@ bool MessagesManager::is_active_message_reply_info(DialogId dialog_id, const Mes
return false;
}
if (!reply_info.is_comment) {
if (!reply_info.is_comment_) {
return true;
}
if (!is_broadcast_channel(dialog_id)) {
@ -7109,7 +7109,7 @@ bool MessagesManager::is_active_message_reply_info(DialogId dialog_id, const Mes
return true;
}
if (linked_channel_id != reply_info.channel_id) {
if (linked_channel_id != reply_info.channel_id_) {
return false;
}
@ -7131,9 +7131,9 @@ bool MessagesManager::is_visible_message_reply_info(DialogId dialog_id, const Me
if (!is_active_message_reply_info(dialog_id, m->reply_info)) {
return false;
}
if (m->reply_info.is_comment && is_broadcast &&
td_->contacts_manager_->have_channel_force(m->reply_info.channel_id) &&
!td_->contacts_manager_->have_input_peer_channel(m->reply_info.channel_id, AccessRights::Read)) {
if (m->reply_info.is_comment_ && is_broadcast &&
td_->contacts_manager_->have_channel_force(m->reply_info.channel_id_) &&
!td_->contacts_manager_->have_input_peer_channel(m->reply_info.channel_id_, AccessRights::Read)) {
// keep the comment button while have no information about the linked channel
return false;
}
@ -7237,7 +7237,7 @@ bool MessagesManager::update_message_interaction_info(Dialog *d, Message *m, int
has_reactions = false;
}
bool need_update_reply_info = has_reply_info && m->reply_info.need_update_to(reply_info);
if (has_reply_info && m->reply_info.channel_id == reply_info.channel_id) {
if (has_reply_info && m->reply_info.channel_id_ == reply_info.channel_id_) {
if (need_update_reply_info) {
reply_info.update_max_message_ids(m->reply_info);
} else {
@ -7287,8 +7287,8 @@ bool MessagesManager::update_message_interaction_info(Dialog *d, Message *m, int
need_update = true;
}
if (need_update_reply_info) {
if (m->reply_info.channel_id != reply_info.channel_id) {
if (m->reply_info.channel_id.is_valid() && reply_info.channel_id.is_valid() && m->message_id.is_server()) {
if (m->reply_info.channel_id_ != reply_info.channel_id_) {
if (m->reply_info.channel_id_.is_valid() && reply_info.channel_id_.is_valid() && m->message_id.is_server()) {
LOG(ERROR) << "Reply info of " << FullMessageId{dialog_id, m->message_id} << " changed from " << m->reply_info
<< " to " << reply_info << " from " << source;
}
@ -18571,14 +18571,14 @@ Result<FullMessageId> MessagesManager::get_top_thread_full_message_id(DialogId d
if (dialog_id.get_type() != DialogType::Channel) {
return Status::Error(400, "Chat can't have message threads");
}
if (!m->reply_info.is_empty() && m->reply_info.is_comment) {
if (!m->reply_info.is_empty() && m->reply_info.is_comment_) {
if (!is_visible_message_reply_info(dialog_id, m)) {
return Status::Error(400, "Message has no comments");
}
if (m->message_id.is_yet_unsent()) {
return Status::Error(400, "Message is not sent yet");
}
return FullMessageId{DialogId(m->reply_info.channel_id), m->linked_top_thread_message_id};
return FullMessageId{DialogId(m->reply_info.channel_id_), m->linked_top_thread_message_id};
} else {
if (!m->top_thread_message_id.is_valid()) {
return Status::Error(400, "Message has no thread");
@ -18611,7 +18611,7 @@ void MessagesManager::get_message_thread(DialogId dialog_id, MessageId message_i
}
TRY_RESULT_PROMISE(promise, top_thread_full_message_id, get_top_thread_full_message_id(dialog_id, m));
if ((m->reply_info.is_empty() || !m->reply_info.is_comment) &&
if ((m->reply_info.is_empty() || !m->reply_info.is_comment_) &&
top_thread_full_message_id.get_message_id() != m->message_id) {
CHECK(dialog_id == top_thread_full_message_id.get_dialog_id());
// get information about the thread from the top message
@ -18724,11 +18724,11 @@ void MessagesManager::on_get_discussion_message(DialogId dialog_id, MessageId me
}
DialogId expected_dialog_id;
if (m->reply_info.is_comment) {
if (m->reply_info.is_comment_) {
if (!is_active_message_reply_info(dialog_id, m->reply_info)) {
return promise.set_error(Status::Error(400, "Message has no comments"));
}
expected_dialog_id = DialogId(m->reply_info.channel_id);
expected_dialog_id = DialogId(m->reply_info.channel_id_);
} else {
if (!m->top_thread_message_id.is_valid()) {
return promise.set_error(Status::Error(400, "Message has no thread"));
@ -18736,7 +18736,7 @@ void MessagesManager::on_get_discussion_message(DialogId dialog_id, MessageId me
expected_dialog_id = dialog_id;
}
if (expected_dialog_id != dialog_id && m->reply_info.is_comment &&
if (expected_dialog_id != dialog_id && m->reply_info.is_comment_ &&
m->linked_top_thread_message_id != message_thread_info.message_ids.back()) {
auto linked_d = get_dialog_force(expected_dialog_id, "on_get_discussion_message 2");
CHECK(linked_d != nullptr);
@ -18793,7 +18793,7 @@ td_api::object_ptr<td_api::messageThreadInfo> MessagesManager::get_message_threa
top_thread_message_id = info.message_ids.back();
if (can_send_message(d->dialog_id).is_ok()) {
const Message *m = get_message_force(d, top_thread_message_id, "get_message_thread_info_object 2");
if (m != nullptr && !m->reply_info.is_comment && is_active_message_reply_info(d->dialog_id, m->reply_info)) {
if (m != nullptr && !m->reply_info.is_comment_ && is_active_message_reply_info(d->dialog_id, m->reply_info)) {
draft_message = get_draft_message_object(m->thread_draft_message);
}
}
@ -19513,13 +19513,13 @@ void MessagesManager::on_get_message_link_message(MessageLinkInfo &&info, Dialog
auto message_id = info.message_id;
Message *m = get_message_force({dialog_id, message_id}, "on_get_message_link_message");
if (info.comment_message_id == MessageId() || m == nullptr || !is_broadcast_channel(dialog_id) ||
!m->reply_info.is_comment || !is_active_message_reply_info(dialog_id, m->reply_info)) {
!m->reply_info.is_comment_ || !is_active_message_reply_info(dialog_id, m->reply_info)) {
return promise.set_value(std::move(info));
}
if (td_->contacts_manager_->have_channel_force(m->reply_info.channel_id)) {
force_create_dialog(DialogId(m->reply_info.channel_id), "on_get_message_link_message");
on_get_message_link_discussion_message(std::move(info), DialogId(m->reply_info.channel_id), std::move(promise));
if (td_->contacts_manager_->have_channel_force(m->reply_info.channel_id_)) {
force_create_dialog(DialogId(m->reply_info.channel_id_), "on_get_message_link_message");
on_get_message_link_discussion_message(std::move(info), DialogId(m->reply_info.channel_id_), std::move(promise));
return;
}
@ -19533,7 +19533,7 @@ void MessagesManager::on_get_message_link_message(MessageLinkInfo &&info, Dialog
});
td_->create_handler<GetDiscussionMessageQuery>(std::move(query_promise))
->send(dialog_id, message_id, DialogId(m->reply_info.channel_id), MessageId());
->send(dialog_id, message_id, DialogId(m->reply_info.channel_id_), MessageId());
}
void MessagesManager::on_get_message_link_discussion_message(MessageLinkInfo &&info, DialogId comment_dialog_id,
@ -20408,7 +20408,7 @@ Status MessagesManager::set_dialog_draft_message(DialogId dialog_id, MessageId t
CHECK(top_thread_message_id.is_valid());
CHECK(top_thread_message_id.is_server());
auto m = get_message_force(d, top_thread_message_id, "set_dialog_draft_message");
if (m == nullptr || m->reply_info.is_comment || !is_active_message_reply_info(dialog_id, m->reply_info)) {
if (m == nullptr || m->reply_info.is_comment_ || !is_active_message_reply_info(dialog_id, m->reply_info)) {
return Status::OK();
}
@ -21423,12 +21423,12 @@ Status MessagesManager::view_messages(DialogId dialog_id, MessageId top_thread_m
MessageId max_thread_message_id;
Message *top_m = get_message_force(d, top_thread_message_id, "view_messages 2");
if (top_m != nullptr && is_active_message_reply_info(dialog_id, top_m->reply_info)) {
prev_last_read_inbox_message_id = top_m->reply_info.last_read_inbox_message_id;
prev_last_read_inbox_message_id = top_m->reply_info.last_read_inbox_message_id_;
if (top_m->reply_info.update_max_message_ids(MessageId(), max_message_id, MessageId())) {
on_message_reply_info_changed(dialog_id, top_m);
on_message_changed(d, top_m, true, "view_messages 3");
}
max_thread_message_id = top_m->reply_info.max_message_id;
max_thread_message_id = top_m->reply_info.max_message_id_;
if (is_discussion_message(dialog_id, top_m)) {
auto linked_dialog_id = top_m->forward_info->from_dialog_id;
@ -21437,15 +21437,15 @@ Status MessagesManager::view_messages(DialogId dialog_id, MessageId top_thread_m
CHECK(linked_dialog_id.get_type() == DialogType::Channel);
auto *linked_m = get_message_force(linked_d, top_m->forward_info->from_message_id, "view_messages 4");
if (linked_m != nullptr && is_active_message_reply_info(linked_dialog_id, linked_m->reply_info)) {
if (linked_m->reply_info.last_read_inbox_message_id < prev_last_read_inbox_message_id) {
prev_last_read_inbox_message_id = linked_m->reply_info.last_read_inbox_message_id;
if (linked_m->reply_info.last_read_inbox_message_id_ < prev_last_read_inbox_message_id) {
prev_last_read_inbox_message_id = linked_m->reply_info.last_read_inbox_message_id_;
}
if (linked_m->reply_info.update_max_message_ids(MessageId(), max_message_id, MessageId())) {
on_message_reply_info_changed(linked_dialog_id, linked_m);
on_message_changed(linked_d, linked_m, true, "view_messages 5");
}
if (linked_m->reply_info.max_message_id > max_thread_message_id) {
max_thread_message_id = linked_m->reply_info.max_message_id;
if (linked_m->reply_info.max_message_id_ > max_thread_message_id) {
max_thread_message_id = linked_m->reply_info.max_message_id_;
}
}
}
@ -22542,7 +22542,7 @@ void MessagesManager::read_message_thread_history_on_server_impl(Dialog *d, Mess
const Message *m = get_message_force(d, top_thread_message_id, "read_message_thread_history_on_server_impl");
if (m != nullptr) {
auto message_id = m->reply_info.last_read_inbox_message_id.get_prev_server_message_id();
auto message_id = m->reply_info.last_read_inbox_message_id_.get_prev_server_message_id();
if (message_id > max_message_id) {
max_message_id = message_id;
}
@ -22670,7 +22670,7 @@ std::pair<DialogId, vector<MessageId>> MessagesManager::get_message_thread_histo
return {};
}
top_thread_full_message_id = r_top_thread_full_message_id.move_as_ok();
if ((m->reply_info.is_empty() || !m->reply_info.is_comment) &&
if ((m->reply_info.is_empty() || !m->reply_info.is_comment_) &&
top_thread_full_message_id.get_message_id() != m->message_id) {
CHECK(dialog_id == top_thread_full_message_id.get_dialog_id());
// get information about the thread from the top message
@ -22679,7 +22679,7 @@ std::pair<DialogId, vector<MessageId>> MessagesManager::get_message_thread_histo
}
if (!top_thread_full_message_id.get_message_id().is_valid()) {
CHECK(m->reply_info.is_comment);
CHECK(m->reply_info.is_comment_);
get_message_thread(
dialog_id, message_id,
PromiseCreator::lambda([promise = std::move(promise)](Result<MessageThreadInfo> &&result) mutable {
@ -25667,12 +25667,12 @@ unique_ptr<MessagesManager::Message> MessagesManager::create_message_to_send(
}
return !reply_to_message_id.is_valid();
}()) {
m->reply_info.reply_count = 0;
m->reply_info.reply_count_ = 0;
if (is_channel_post) {
auto linked_channel_id = td_->contacts_manager_->get_channel_linked_channel_id(dialog_id.get_channel_id());
if (linked_channel_id.is_valid()) {
m->reply_info.is_comment = true;
m->reply_info.channel_id = linked_channel_id;
m->reply_info.is_comment_ = true;
m->reply_info.channel_id_ = linked_channel_id;
}
}
}
@ -26013,11 +26013,11 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, const
dependencies.add_dialog_and_dependencies(m->forward_info->sender_dialog_id);
dependencies.add_dialog_and_dependencies(m->forward_info->from_dialog_id);
}
for (const auto &replier_min_channel : m->reply_info.replier_min_channels) {
for (const auto &replier_min_channel : m->reply_info.replier_min_channels_) {
LOG(INFO) << "Add min replied " << replier_min_channel.first;
td_->contacts_manager_->add_min_channel(replier_min_channel.first, replier_min_channel.second);
}
for (auto recent_replier_dialog_id : m->reply_info.recent_replier_dialog_ids) {
for (auto recent_replier_dialog_id : m->reply_info.recent_replier_dialog_ids_) {
// don't load the dialog itself
// it will be created in get_message_reply_info_object if needed
dependencies.add_dialog_dependencies(recent_replier_dialog_id);
@ -33568,8 +33568,8 @@ void MessagesManager::on_dialog_linked_channel_updated(DialogId dialog_id, Chann
vector<MessageId> message_ids;
find_messages(d->messages.get(), message_ids, [old_linked_channel_id, new_linked_channel_id](const Message *m) {
return !m->reply_info.is_empty() && m->reply_info.channel_id.is_valid() &&
(m->reply_info.channel_id == old_linked_channel_id || m->reply_info.channel_id == new_linked_channel_id);
return !m->reply_info.is_empty() && m->reply_info.channel_id_.is_valid() &&
(m->reply_info.channel_id_ == old_linked_channel_id || m->reply_info.channel_id_ == new_linked_channel_id);
});
LOG(INFO) << "Found discussion messages " << message_ids;
for (auto message_id : message_ids) {