Add {add,delete}_random_id_to_message_id_correspondence functions.

GitOrigin-RevId: 7701ea29659c355da408e97bf642529113e9d7ff
This commit is contained in:
levlam 2018-10-24 22:49:50 +03:00
parent 54ec85ff22
commit 043602bfc2
2 changed files with 23 additions and 11 deletions

View File

@ -10186,6 +10186,20 @@ unique_ptr<MessagesManager::Message> MessagesManager::delete_message(Dialog *d,
return do_delete_message(d, message_id, is_permanently_deleted, false, need_update_dialog_pos, source); return do_delete_message(d, message_id, is_permanently_deleted, false, need_update_dialog_pos, source);
} }
void MessagesManager::add_random_id_to_message_id_correspondence(Dialog *d, int64 random_id, MessageId message_id) {
CHECK(d != nullptr);
CHECK(d->dialog_id.get_type() == DialogType::SecretChat);
LOG(INFO) << "Add correspondence from random_id " << random_id << " to " << message_id << " in " << d->dialog_id;
d->random_id_to_message_id[random_id] = message_id;
}
void MessagesManager::delete_random_id_to_message_id_correspondence(Dialog *d, int64 random_id, MessageId message_id) {
CHECK(d != nullptr);
CHECK(d->dialog_id.get_type() == DialogType::SecretChat);
LOG(INFO) << "Delete correspondence from random_id " << random_id << " to " << message_id << " in " << d->dialog_id;
d->random_id_to_message_id.erase(random_id);
}
// DO NOT FORGET TO ADD ALL CHANGES OF THIS FUNCTION AS WELL TO do_delete_all_dialog_messages // DO NOT FORGET TO ADD ALL CHANGES OF THIS FUNCTION AS WELL TO do_delete_all_dialog_messages
unique_ptr<MessagesManager::Message> MessagesManager::do_delete_message(Dialog *d, MessageId message_id, unique_ptr<MessagesManager::Message> MessagesManager::do_delete_message(Dialog *d, MessageId message_id,
bool is_permanently_deleted, bool is_permanently_deleted,
@ -10437,9 +10451,7 @@ unique_ptr<MessagesManager::Message> MessagesManager::do_delete_message(Dialog *
// nothing to do // nothing to do
break; break;
case DialogType::SecretChat: case DialogType::SecretChat:
LOG(INFO) << "Delete correspondence random_id " << result->random_id << " to " << message_id << " in " delete_random_id_to_message_id_correspondence(d, result->random_id, message_id);
<< d->dialog_id;
d->random_id_to_message_id.erase(result->random_id);
break; break;
case DialogType::None: case DialogType::None:
default: default:
@ -10485,8 +10497,7 @@ void MessagesManager::do_delete_all_dialog_messages(Dialog *d, unique_ptr<Messag
// nothing to do // nothing to do
break; break;
case DialogType::SecretChat: case DialogType::SecretChat:
LOG(INFO) << "Delete correspondence random_id " << m->random_id << " to " << message_id << " in " << d->dialog_id; delete_random_id_to_message_id_correspondence(d, m->random_id, message_id);
d->random_id_to_message_id.erase(m->random_id);
break; break;
case DialogType::None: case DialogType::None:
default: default:
@ -17742,10 +17753,8 @@ void MessagesManager::on_send_message_file_part_missing(int64 random_id, int bad
} while (m->random_id == 0 || message_random_ids_.find(m->random_id) != message_random_ids_.end()); } while (m->random_id == 0 || message_random_ids_.find(m->random_id) != message_random_ids_.end());
message_random_ids_.insert(m->random_id); message_random_ids_.insert(m->random_id);
LOG(INFO) << "Replace random_id from " << random_id << " to " << m->random_id << " in " << m->message_id << " in " delete_random_id_to_message_id_correspondence(d, random_id, m->message_id);
<< dialog_id; add_random_id_to_message_id_correspondence(d, m->random_id, m->message_id);
d->random_id_to_message_id.erase(random_id);
d->random_id_to_message_id[m->random_id] = m->message_id;
auto logevent = SendMessageLogEvent(dialog_id, m); auto logevent = SendMessageLogEvent(dialog_id, m);
auto storer = LogEventStorerImpl<SendMessageLogEvent>(logevent); auto storer = LogEventStorerImpl<SendMessageLogEvent>(logevent);
@ -20260,8 +20269,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
// nothing to do // nothing to do
break; break;
case DialogType::SecretChat: case DialogType::SecretChat:
LOG(INFO) << "Add correspondence random_id " << (*v)->random_id << " to " << message_id << " in " << dialog_id; add_random_id_to_message_id_correspondence(d, (*v)->random_id, message_id);
d->random_id_to_message_id[(*v)->random_id] = message_id;
break; break;
case DialogType::None: case DialogType::None:
default: default:

View File

@ -1426,6 +1426,10 @@ class MessagesManager : public Actor {
void delete_message_files(const Message *m) const; void delete_message_files(const Message *m) const;
static void add_random_id_to_message_id_correspondence(Dialog *d, int64 random_id, MessageId message_id);
static void delete_random_id_to_message_id_correspondence(Dialog *d, int64 random_id, MessageId message_id);
void do_delete_message_logevent(const DeleteMessageLogEvent &logevent) const; void do_delete_message_logevent(const DeleteMessageLogEvent &logevent) const;
void attach_message_to_previous(Dialog *d, MessageId message_id, const char *source); void attach_message_to_previous(Dialog *d, MessageId message_id, const char *source);