Update reply info if linked_channel_id is changed.

GitOrigin-RevId: 629721095881d2c9a401519d26f75bbbba4446f9
This commit is contained in:
levlam 2020-10-01 22:28:54 +03:00
parent 1169365710
commit ca1594c8ec
2 changed files with 13 additions and 7 deletions

View File

@ -36,7 +36,7 @@ MessageReplyInfo::MessageReplyInfo(tl_object_ptr<telegram_api::messageReplies> &
}
if (is_comment) {
for (auto &peer : reply_info->recent_repliers_) {
for (const auto &peer : reply_info->recent_repliers_) {
DialogId dialog_id(peer);
if (dialog_id.is_valid()) {
recent_replier_dialog_ids.push_back(dialog_id);
@ -58,6 +58,7 @@ MessageReplyInfo::MessageReplyInfo(tl_object_ptr<telegram_api::messageReplies> &
<< ", but max_message_id = " << max_message_id;
max_message_id = last_read_inbox_message_id;
}
LOG(DEBUG) << "Parsed " << oneline(to_string(reply_info)) << " to " << *this;
}
bool MessageReplyInfo::need_update_to(const MessageReplyInfo &other) const {
@ -68,7 +69,8 @@ bool MessageReplyInfo::need_update_to(const MessageReplyInfo &other) const {
if (other.pts < pts) {
return false;
}
return reply_count != other.reply_count || recent_replier_dialog_ids != other.recent_replier_dialog_ids;
return reply_count != other.reply_count || recent_replier_dialog_ids != other.recent_replier_dialog_ids ||
is_comment != other.is_comment || channel_id != other.channel_id;
}
bool MessageReplyInfo::update_max_message_ids(const MessageReplyInfo &other) {

View File

@ -6596,7 +6596,7 @@ bool MessagesManager::update_message_interaction_info(DialogId dialog_id, Messag
}
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()) {
if (m->reply_info.channel_id.is_valid() && reply_info.channel_id.is_valid() && m->message_id.is_server()) {
LOG(ERROR) << "Reply info changed from " << m->reply_info << " to " << reply_info;
}
}
@ -21812,13 +21812,17 @@ MessagesManager::Message *MessagesManager::get_message_to_send(
if (td_->auth_manager_->is_bot()) {
return false;
}
if (is_channel_post) {
return td_->contacts_manager_->get_channel_has_linked_channel(dialog_id.get_channel_id());
}
return !reply_to_message_id.is_valid() &&
return (is_channel_post || !reply_to_message_id.is_valid()) &&
td_->contacts_manager_->get_channel_has_linked_channel(dialog_id.get_channel_id());
}()) {
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->content = std::move(content);
m->forward_info = std::move(forward_info);