Better get_message_file_source_id.
GitOrigin-RevId: 4de6e99640bb9fc4b6be8ddbc89817be3d5e1f99
This commit is contained in:
parent
d805569459
commit
51b3711171
@ -13700,6 +13700,11 @@ void MessagesManager::save_active_live_locations() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileSourceId MessagesManager::get_message_file_source_id(FullMessageId full_message_id) {
|
FileSourceId MessagesManager::get_message_file_source_id(FullMessageId full_message_id) {
|
||||||
|
if (full_message_id.get_dialog_id().get_type() == DialogType::SecretChat ||
|
||||||
|
!full_message_id.get_message_id().is_server()) {
|
||||||
|
return FileSourceId();
|
||||||
|
}
|
||||||
|
|
||||||
auto &file_source_id = full_message_id_to_file_source_id_[full_message_id];
|
auto &file_source_id = full_message_id_to_file_source_id_[full_message_id];
|
||||||
if (!file_source_id.is_valid()) {
|
if (!file_source_id.is_valid()) {
|
||||||
file_source_id = td_->file_reference_manager_->create_message_file_source(full_message_id);
|
file_source_id = td_->file_reference_manager_->create_message_file_source(full_message_id);
|
||||||
@ -13708,34 +13713,32 @@ FileSourceId MessagesManager::get_message_file_source_id(FullMessageId full_mess
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::add_message_file_sources(DialogId dialog_id, const Message *m) {
|
void MessagesManager::add_message_file_sources(DialogId dialog_id, const Message *m) {
|
||||||
if (dialog_id.get_type() == DialogType::SecretChat || !m->message_id.is_server()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto file_ids = get_message_content_file_ids(m->content.get(), td_);
|
auto file_ids = get_message_content_file_ids(m->content.get(), td_);
|
||||||
if (file_ids.empty()) {
|
if (file_ids.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do not create file_source_id for messages without file_ids
|
||||||
auto file_source_id = get_message_file_source_id(FullMessageId(dialog_id, m->message_id));
|
auto file_source_id = get_message_file_source_id(FullMessageId(dialog_id, m->message_id));
|
||||||
for (auto file_id : file_ids) {
|
if (file_source_id.is_valid()) {
|
||||||
td_->file_manager_->add_file_source(file_id, file_source_id);
|
for (auto file_id : file_ids) {
|
||||||
|
td_->file_manager_->add_file_source(file_id, file_source_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::remove_message_file_sources(DialogId dialog_id, const Message *m) {
|
void MessagesManager::remove_message_file_sources(DialogId dialog_id, const Message *m) {
|
||||||
if (dialog_id.get_type() == DialogType::SecretChat || !m->message_id.is_server()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto file_ids = get_message_content_file_ids(m->content.get(), td_);
|
auto file_ids = get_message_content_file_ids(m->content.get(), td_);
|
||||||
if (file_ids.empty()) {
|
if (file_ids.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do not create file_source_id for messages without file_ids
|
||||||
auto file_source_id = get_message_file_source_id(FullMessageId(dialog_id, m->message_id));
|
auto file_source_id = get_message_file_source_id(FullMessageId(dialog_id, m->message_id));
|
||||||
for (auto file_id : file_ids) {
|
if (file_source_id.is_valid()) {
|
||||||
td_->file_manager_->remove_file_source(file_id, file_source_id);
|
for (auto file_id : file_ids) {
|
||||||
|
td_->file_manager_->remove_file_source(file_id, file_source_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21065,8 +21068,8 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
|
|||||||
}
|
}
|
||||||
auto new_file_ids = get_message_content_file_ids((*v)->content.get(), td_);
|
auto new_file_ids = get_message_content_file_ids((*v)->content.get(), td_);
|
||||||
if (new_file_ids != old_file_ids) {
|
if (new_file_ids != old_file_ids) {
|
||||||
if (dialog_id.get_type() != DialogType::SecretChat && message_id.is_server()) {
|
auto file_source_id = get_message_file_source_id(FullMessageId(dialog_id, message_id));
|
||||||
auto file_source_id = get_message_file_source_id(FullMessageId(dialog_id, message_id));
|
if (file_source_id.is_valid()) {
|
||||||
td_->file_manager_->change_files_source(file_source_id, old_file_ids, new_file_ids);
|
td_->file_manager_->change_files_source(file_source_id, old_file_ids, new_file_ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1350,6 +1350,7 @@ void FileManager::add_file_source(FileId file_id, FileSourceId file_source_id) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CHECK(file_source_id.is_valid());
|
||||||
send_closure(G()->file_reference_manager(), &FileReferenceManager::add_file_source, node->main_file_id_,
|
send_closure(G()->file_reference_manager(), &FileReferenceManager::add_file_source, node->main_file_id_,
|
||||||
file_source_id);
|
file_source_id);
|
||||||
}
|
}
|
||||||
@ -1359,6 +1360,8 @@ void FileManager::remove_file_source(FileId file_id, FileSourceId file_source_id
|
|||||||
if (!node) {
|
if (!node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CHECK(file_source_id.is_valid());
|
||||||
send_closure(G()->file_reference_manager(), &FileReferenceManager::remove_file_source, node->main_file_id_,
|
send_closure(G()->file_reference_manager(), &FileReferenceManager::remove_file_source, node->main_file_id_,
|
||||||
file_source_id);
|
file_source_id);
|
||||||
}
|
}
|
||||||
@ -1368,6 +1371,7 @@ void FileManager::change_files_source(FileSourceId file_source_id, const vector<
|
|||||||
if (old_file_ids == new_file_ids) {
|
if (old_file_ids == new_file_ids) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
CHECK(file_source_id.is_valid());
|
||||||
|
|
||||||
auto old_main_file_ids = get_main_file_ids(old_file_ids);
|
auto old_main_file_ids = get_main_file_ids(old_file_ids);
|
||||||
auto new_main_file_ids = get_main_file_ids(new_file_ids);
|
auto new_main_file_ids = get_main_file_ids(new_file_ids);
|
||||||
|
Reference in New Issue
Block a user