Register replies to messages in different chats.
This commit is contained in:
parent
1886bcf850
commit
8096cf0439
@ -27145,40 +27145,43 @@ void MessagesManager::update_message_max_reply_media_timestamp_in_replied_messag
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO) << "Update max_reply_media_timestamp for replies of " << reply_to_message_id << " in " << dialog_id;
|
LOG(INFO) << "Update max_reply_media_timestamp for replies of " << full_message_id;
|
||||||
|
|
||||||
Dialog *d = get_dialog(dialog_id);
|
for (auto replied_full_message_id : it->second) {
|
||||||
CHECK(d != nullptr);
|
auto replied_dialog_id = replied_full_message_id.get_dialog_id();
|
||||||
for (auto message_id : it->second) {
|
Dialog *d = get_dialog(replied_dialog_id);
|
||||||
auto m = get_message(d, message_id);
|
auto m = get_message(d, replied_full_message_id.get_message_id());
|
||||||
CHECK(m != nullptr);
|
CHECK(m != nullptr);
|
||||||
|
CHECK((m->reply_in_dialog_id.is_valid() ? m->reply_in_dialog_id : replied_dialog_id) == dialog_id);
|
||||||
CHECK(m->reply_to_message_id == reply_to_message_id);
|
CHECK(m->reply_to_message_id == reply_to_message_id);
|
||||||
update_message_max_reply_media_timestamp(d, m, true);
|
update_message_max_reply_media_timestamp(d, m, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::register_message_reply(DialogId dialog_id, const Message *m) {
|
void MessagesManager::register_message_reply(DialogId dialog_id, const Message *m) {
|
||||||
if (!m->reply_to_message_id.is_valid() || m->reply_to_message_id.is_yet_unsent() ||
|
if (!m->reply_to_message_id.is_valid() || m->reply_to_message_id.is_yet_unsent() || td_->auth_manager_->is_bot()) {
|
||||||
m->reply_in_dialog_id != DialogId() || td_->auth_manager_->is_bot()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_media_timestamps(get_message_content_text(m->content.get()), 0, std::numeric_limits<int32>::max())) {
|
if (has_media_timestamps(get_message_content_text(m->content.get()), 0, std::numeric_limits<int32>::max())) {
|
||||||
LOG(INFO) << "Register " << m->message_id << " in " << dialog_id << " as reply to " << m->reply_to_message_id;
|
FullMessageId full_message_id{m->reply_in_dialog_id.is_valid() ? m->reply_in_dialog_id : dialog_id,
|
||||||
FullMessageId full_message_id{dialog_id, m->reply_to_message_id};
|
m->reply_to_message_id};
|
||||||
bool is_inserted = replied_by_media_timestamp_messages_[full_message_id].insert(m->message_id).second;
|
LOG(INFO) << "Register " << m->message_id << " in " << dialog_id << " as reply to " << full_message_id;
|
||||||
|
bool is_inserted = replied_by_media_timestamp_messages_[full_message_id].insert({dialog_id, m->message_id}).second;
|
||||||
CHECK(is_inserted);
|
CHECK(is_inserted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::reregister_message_reply(DialogId dialog_id, const Message *m) {
|
void MessagesManager::reregister_message_reply(DialogId dialog_id, const Message *m) {
|
||||||
if (!m->reply_to_message_id.is_valid() || m->reply_to_message_id.is_yet_unsent() ||
|
if (!m->reply_to_message_id.is_valid() || m->reply_to_message_id.is_yet_unsent() || td_->auth_manager_->is_bot()) {
|
||||||
m->reply_in_dialog_id != DialogId() || td_->auth_manager_->is_bot()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = replied_by_media_timestamp_messages_.find({dialog_id, m->reply_to_message_id});
|
FullMessageId full_message_id{m->reply_in_dialog_id.is_valid() ? m->reply_in_dialog_id : dialog_id,
|
||||||
bool was_registered = it != replied_by_media_timestamp_messages_.end() && it->second.count(m->message_id) > 0;
|
m->reply_to_message_id};
|
||||||
|
auto it = replied_by_media_timestamp_messages_.find(full_message_id);
|
||||||
|
bool was_registered =
|
||||||
|
it != replied_by_media_timestamp_messages_.end() && it->second.count({dialog_id, m->message_id}) > 0;
|
||||||
bool need_register =
|
bool need_register =
|
||||||
has_media_timestamps(get_message_content_text(m->content.get()), 0, std::numeric_limits<int32>::max());
|
has_media_timestamps(get_message_content_text(m->content.get()), 0, std::numeric_limits<int32>::max());
|
||||||
if (was_registered == need_register) {
|
if (was_registered == need_register) {
|
||||||
@ -27192,18 +27195,19 @@ void MessagesManager::reregister_message_reply(DialogId dialog_id, const Message
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::unregister_message_reply(DialogId dialog_id, const Message *m) {
|
void MessagesManager::unregister_message_reply(DialogId dialog_id, const Message *m) {
|
||||||
if (!m->reply_to_message_id.is_valid() || m->reply_to_message_id.is_yet_unsent() ||
|
if (!m->reply_to_message_id.is_valid() || m->reply_to_message_id.is_yet_unsent() || td_->auth_manager_->is_bot()) {
|
||||||
m->reply_in_dialog_id != DialogId() || td_->auth_manager_->is_bot()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto it = replied_by_media_timestamp_messages_.find({dialog_id, m->reply_to_message_id});
|
FullMessageId full_message_id{m->reply_in_dialog_id.is_valid() ? m->reply_in_dialog_id : dialog_id,
|
||||||
|
m->reply_to_message_id};
|
||||||
|
auto it = replied_by_media_timestamp_messages_.find(full_message_id);
|
||||||
if (it == replied_by_media_timestamp_messages_.end()) {
|
if (it == replied_by_media_timestamp_messages_.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto is_deleted = it->second.erase(m->message_id) > 0;
|
auto is_deleted = it->second.erase({dialog_id, m->message_id}) > 0;
|
||||||
if (is_deleted) {
|
if (is_deleted) {
|
||||||
LOG(INFO) << "Unregister " << m->message_id << " in " << dialog_id << " as reply to " << m->reply_to_message_id;
|
LOG(INFO) << "Unregister " << m->message_id << " in " << dialog_id << " as reply to " << full_message_id;
|
||||||
if (it->second.empty()) {
|
if (it->second.empty()) {
|
||||||
replied_by_media_timestamp_messages_.erase(it);
|
replied_by_media_timestamp_messages_.erase(it);
|
||||||
}
|
}
|
||||||
|
@ -3420,7 +3420,7 @@ class MessagesManager final : public Actor {
|
|||||||
FlatHashMap<FullMessageId, FlatHashSet<MessageId, MessageIdHash>, FullMessageIdHash> replied_yet_unsent_messages_;
|
FlatHashMap<FullMessageId, FlatHashSet<MessageId, MessageIdHash>, FullMessageIdHash> replied_yet_unsent_messages_;
|
||||||
|
|
||||||
// full_message_id -> replies with media timestamps
|
// full_message_id -> replies with media timestamps
|
||||||
FlatHashMap<FullMessageId, FlatHashSet<MessageId, MessageIdHash>, FullMessageIdHash>
|
FlatHashMap<FullMessageId, FlatHashSet<FullMessageId, FullMessageIdHash>, FullMessageIdHash>
|
||||||
replied_by_media_timestamp_messages_;
|
replied_by_media_timestamp_messages_;
|
||||||
|
|
||||||
struct ActiveDialogAction {
|
struct ActiveDialogAction {
|
||||||
|
Loading…
Reference in New Issue
Block a user