Fix MessageReaction::set_my_recent_chooser_dialog_id.

This commit is contained in:
levlam 2023-05-01 18:09:27 +03:00
parent ac81a35283
commit e4a15cc0ef
2 changed files with 14 additions and 6 deletions

View File

@ -472,11 +472,14 @@ void MessageReaction::set_my_recent_chooser_dialog_id(DialogId my_dialog_id) {
if (!my_recent_chooser_dialog_id_.is_valid() || my_recent_chooser_dialog_id_ == my_dialog_id) {
return;
}
if (td::contains(recent_chooser_dialog_ids_, my_dialog_id)) {
my_recent_chooser_dialog_id_ = my_dialog_id;
} else {
my_recent_chooser_dialog_id_ = DialogId();
td::remove(recent_chooser_dialog_ids_, my_dialog_id);
for (auto &dialog_id : recent_chooser_dialog_ids_) {
if (dialog_id == my_recent_chooser_dialog_id_) {
dialog_id = my_dialog_id;
}
}
CHECK(td::contains(recent_chooser_dialog_ids_, my_dialog_id));
my_recent_chooser_dialog_id_ = my_dialog_id;
}
td_api::object_ptr<td_api::messageReaction> MessageReaction::get_message_reaction_object(Td *td, UserId my_user_id,
@ -523,6 +526,9 @@ StringBuilder &operator<<(StringBuilder &string_builder, const MessageReaction &
string_builder << '[' << reaction.reaction_ << (reaction.is_chosen_ ? " X " : " x ") << reaction.choose_count_;
if (!reaction.recent_chooser_dialog_ids_.empty()) {
string_builder << " by " << reaction.recent_chooser_dialog_ids_;
if (reaction.my_recent_chooser_dialog_id_.is_valid()) {
string_builder << " and my " << reaction.my_recent_chooser_dialog_id_;
}
}
return string_builder << ']';
}

View File

@ -7129,12 +7129,14 @@ bool MessagesManager::update_message_interaction_info(Dialog *d, Message *m, int
if (has_reactions) {
auto it = pending_reactions_.find({dialog_id, m->message_id});
if (it != pending_reactions_.end()) {
LOG(INFO) << "Ignore reactions, because have a pending message reaction";
LOG(INFO) << "Ignore reactions for " << FullMessageId{dialog_id, m->message_id}
<< ", because they are being changed";
has_reactions = false;
it->second.was_updated = true;
}
if (has_reactions && pending_read_reactions_.count({dialog_id, m->message_id}) > 0) {
LOG(INFO) << "Ignore reactions, because have a pending message reaction read";
LOG(INFO) << "Ignore reactions for " << FullMessageId{dialog_id, m->message_id}
<< ", because they are being read";
has_reactions = false;
}
}