Add separate reget_message_from_server_if_needed function.

GitOrigin-RevId: 18b0a4f38ac429890832851370ff6371f6496ff1
This commit is contained in:
levlam 2019-11-30 20:22:44 +03:00
parent 7ea11b2150
commit af04f95daa
2 changed files with 14 additions and 12 deletions

View File

@ -25174,14 +25174,10 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
on_dialog_updated(dialog_id, "update_has_contact_registered_message"); on_dialog_updated(dialog_id, "update_has_contact_registered_message");
} }
if (message_id.is_server() && dialog_id.get_type() != DialogType::SecretChat && reget_message_from_server_if_needed(dialog_id, m);
(need_reget_message_content(m->content.get()) || (m->legacy_layer != 0 && m->legacy_layer < MTPROTO_LAYER))) {
FullMessageId full_message_id{dialog_id, message_id};
LOG(INFO) << "Reget from server " << full_message_id;
get_message_from_server(full_message_id, Auto());
}
add_message_file_sources(dialog_id, m); add_message_file_sources(dialog_id, m);
register_message_content(td_, m->content.get(), {dialog_id, message_id}); register_message_content(td_, m->content.get(), {dialog_id, message_id});
if (*need_update && message_id.is_server() && message_content_type == MessageContentType::PinMessage) { if (*need_update && message_id.is_server() && message_content_type == MessageContentType::PinMessage) {
@ -25326,12 +25322,7 @@ MessagesManager::Message *MessagesManager::add_scheduled_message_to_dialog(Dialo
add_message_to_database(d, m, "add_scheduled_message_to_dialog"); add_message_to_database(d, m, "add_scheduled_message_to_dialog");
} }
if (message_id.is_scheduled_server() && reget_message_from_server_if_needed(dialog_id, m);
(need_reget_message_content(m->content.get()) || (m->legacy_layer != 0 && m->legacy_layer < MTPROTO_LAYER))) {
FullMessageId full_message_id{dialog_id, message_id};
LOG(INFO) << "Reget from server " << full_message_id;
get_message_from_server(full_message_id, Auto());
}
add_message_file_sources(dialog_id, m); add_message_file_sources(dialog_id, m);
@ -27753,6 +27744,15 @@ void MessagesManager::after_get_channel_difference(DialogId dialog_id, bool succ
} }
} }
void MessagesManager::reget_message_from_server_if_needed(DialogId dialog_id, const Message *m) {
if (m->message_id.is_any_server() && dialog_id.get_type() != DialogType::SecretChat &&
(need_reget_message_content(m->content.get()) || (m->legacy_layer != 0 && m->legacy_layer < MTPROTO_LAYER))) {
FullMessageId full_message_id{dialog_id, m->message_id};
LOG(INFO) << "Reget from server " << full_message_id;
get_message_from_server(full_message_id, Auto());
}
}
void MessagesManager::speculatively_update_channel_participants(DialogId dialog_id, const Message *m) { void MessagesManager::speculatively_update_channel_participants(DialogId dialog_id, const Message *m) {
CHECK(m != nullptr); CHECK(m != nullptr);
if (!m->message_id.is_any_server() || dialog_id.get_type() != DialogType::Channel || !m->sender_user_id.is_valid()) { if (!m->message_id.is_any_server() || dialog_id.get_type() != DialogType::Channel || !m->sender_user_id.is_valid()) {

View File

@ -2268,6 +2268,8 @@ class MessagesManager : public Actor {
void save_recently_found_dialogs(); void save_recently_found_dialogs();
bool load_recently_found_dialogs(Promise<Unit> &promise); bool load_recently_found_dialogs(Promise<Unit> &promise);
void reget_message_from_server_if_needed(DialogId dialog_id, const Message *m);
void speculatively_update_channel_participants(DialogId dialog_id, const Message *m); void speculatively_update_channel_participants(DialogId dialog_id, const Message *m);
void update_sent_message_contents(DialogId dialog_id, const Message *m); void update_sent_message_contents(DialogId dialog_id, const Message *m);