Process request result in MessagesManager actor context.

This commit is contained in:
levlam 2022-08-21 07:24:53 +03:00
parent 092499a7c6
commit acbc2cebf4
2 changed files with 19 additions and 10 deletions

View File

@ -9393,7 +9393,7 @@ void MessagesManager::after_get_difference() {
if (!have_input_peer(dialog_id, AccessRights::Read) || if (!have_input_peer(dialog_id, AccessRights::Read) ||
(d != nullptr && (d != nullptr &&
message_id <= td::max(d->last_clear_history_message_id, d->max_unavailable_message_id))) { message_id <= td::max(d->last_clear_history_message_id, d->max_unavailable_message_id))) {
update_message_ids_to_delete.push_back(it.first); update_message_ids_to_delete.push_back(full_message_id);
} }
break; break;
} }
@ -9408,13 +9408,11 @@ void MessagesManager::after_get_difference() {
dump_debug_message_op(get_dialog(dialog_id)); dump_debug_message_op(get_dialog(dialog_id));
} }
if (message_id <= d->last_new_message_id) { if (message_id <= d->last_new_message_id) {
get_message_from_server(it.first, PromiseCreator::lambda([full_message_id](Result<Unit> result) { get_message_from_server(
if (result.is_error()) { full_message_id,
LOG(WARNING) PromiseCreator::lambda([actor_id = actor_id(this), full_message_id](Result<Unit> result) {
<< "Failed to get missing " << full_message_id << ": " << result.error(); send_closure(actor_id, &MessagesManager::on_restore_missing_message_after_get_difference,
} else { full_message_id, std::move(result));
LOG(WARNING) << "Successfully get missing " << full_message_id;
}
}), }),
"get missing"); "get missing");
} else if (dialog_id.get_type() == DialogType::Channel) { } else if (dialog_id.get_type() == DialogType::Channel) {
@ -9452,6 +9450,15 @@ void MessagesManager::after_get_difference() {
} }
} }
void MessagesManager::on_restore_missing_message_after_get_difference(FullMessageId full_message_id,
Result<Unit> result) {
if (result.is_error()) {
LOG(WARNING) << "Failed to get missing " << full_message_id << ": " << result.error();
} else {
LOG(WARNING) << "Successfully get missing " << full_message_id;
}
}
void MessagesManager::on_get_empty_messages(DialogId dialog_id, const vector<MessageId> &empty_message_ids) { void MessagesManager::on_get_empty_messages(DialogId dialog_id, const vector<MessageId> &empty_message_ids) {
if (!empty_message_ids.empty()) { if (!empty_message_ids.empty()) {
delete_dialog_messages(dialog_id, empty_message_ids, true, true, "on_get_empty_messages"); delete_dialog_messages(dialog_id, empty_message_ids, true, true, "on_get_empty_messages");

View File

@ -2950,6 +2950,8 @@ class MessagesManager final : public Actor {
void ttl_db_loop(double server_now); void ttl_db_loop(double server_now);
void ttl_db_on_result(Result<std::pair<std::vector<MessagesDbMessage>, int32>> r_result, bool dummy); void ttl_db_on_result(Result<std::pair<std::vector<MessagesDbMessage>, int32>> r_result, bool dummy);
void on_restore_missing_message_after_get_difference(FullMessageId full_message_id, Result<Unit> result);
void on_get_message_link_dialog(MessageLinkInfo &&info, Promise<MessageLinkInfo> &&promise); void on_get_message_link_dialog(MessageLinkInfo &&info, Promise<MessageLinkInfo> &&promise);
void on_get_message_link_message(MessageLinkInfo &&info, DialogId dialog_id, Promise<MessageLinkInfo> &&promise); void on_get_message_link_message(MessageLinkInfo &&info, DialogId dialog_id, Promise<MessageLinkInfo> &&promise);