AddFileToDownloads method
This commit is contained in:
parent
e2c7601c2b
commit
a59f262b26
@ -17,6 +17,7 @@
|
||||
#include "td/telegram/DialogFilter.h"
|
||||
#include "td/telegram/DialogFilter.hpp"
|
||||
#include "td/telegram/DialogLocation.h"
|
||||
#include "td/telegram/DownloadManager.h"
|
||||
#include "td/telegram/DraftMessage.h"
|
||||
#include "td/telegram/DraftMessage.hpp"
|
||||
#include "td/telegram/FileReferenceManager.h"
|
||||
@ -39796,4 +39797,21 @@ void MessagesManager::get_current_state(vector<td_api::object_ptr<td_api::Update
|
||||
append(updates, std::move(last_message_updates));
|
||||
}
|
||||
|
||||
void MessagesManager::add_message_file_to_downloads(FullMessageId full_message_id, FileId file_id, int32 priority,
|
||||
Promise<td_api::object_ptr<td_api::file>> promise) {
|
||||
auto message = get_message_force(full_message_id, "add message file to downloads");
|
||||
if (!message) {
|
||||
promise.set_error(Status::Error(400, "Can't find message"));
|
||||
return;
|
||||
}
|
||||
if (!contains(get_message_file_ids(message), file_id)) {
|
||||
promise.set_error(Status::Error(400, "Can't find file in message"));
|
||||
return;
|
||||
}
|
||||
auto search_text = get_message_search_text(message);
|
||||
auto file_source_id = td_->file_reference_manager_->create_message_file_source(full_message_id);
|
||||
td_->download_manager_->add_file(file_id, file_source_id, std::move(search_text), static_cast<int8>(priority));
|
||||
promise.set_value(td_->file_manager_->get_file_object(file_id));
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -980,6 +980,9 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
||||
|
||||
void add_message_file_to_downloads(FullMessageId full_message_id, FileId file_id, int32 priority,
|
||||
Promise<td_api::object_ptr<td_api::file>> promise);
|
||||
|
||||
private:
|
||||
class PendingPtsUpdate {
|
||||
public:
|
||||
|
@ -3501,7 +3501,7 @@ void Td::clear() {
|
||||
LOG(DEBUG) << "ContactsManager actor was cleared" << timer;
|
||||
country_info_manager_actor_.reset();
|
||||
LOG(DEBUG) << "CountryInfoManager actor was cleared" << timer;
|
||||
download_manger_actor_.reset();
|
||||
download_manager_actor_.reset();
|
||||
LOG(DEBUG) << "DownloadManager actor was cleared" << timer;
|
||||
file_manager_actor_.reset();
|
||||
LOG(DEBUG) << "FileManager actor was cleared" << timer;
|
||||
@ -3971,7 +3971,7 @@ void Td::init_managers() {
|
||||
country_info_manager_ = make_unique<CountryInfoManager>(this, create_reference());
|
||||
country_info_manager_actor_ = register_actor("CountryInfoManager", country_info_manager_.get());
|
||||
download_manager_ = DownloadManager::create();
|
||||
download_manger_actor_ = register_actor("DownloadManager", download_manager_.get());
|
||||
download_manager_actor_ = register_actor("DownloadManager", download_manager_.get());
|
||||
// TODO: move this callback somewhere else
|
||||
class DownloadManagerCallback final : public DownloadManager::Callback {
|
||||
public:
|
||||
@ -4006,7 +4006,7 @@ void Td::init_managers() {
|
||||
private:
|
||||
ActorShared<> parent_;
|
||||
};
|
||||
send_closure_later(download_manger_actor_, &DownloadManager::set_callback,
|
||||
send_closure_later(download_manager_actor_, &DownloadManager::set_callback,
|
||||
make_unique<DownloadManagerCallback>(create_reference()));
|
||||
|
||||
game_manager_ = make_unique<GameManager>(this, create_reference());
|
||||
@ -6551,7 +6551,9 @@ void Td::on_request(uint64 id, const td_api::deleteFile &request) {
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::addFileToDownloads &request) {
|
||||
CREATE_REQUEST_PROMISE();
|
||||
promise.set_error(Status::Error(500, "Unsupported"));
|
||||
messages_manager_->add_message_file_to_downloads(
|
||||
FullMessageId(DialogId(request.chat_id_), MessageId(request.message_id_)), FileId(request.file_id_, 0),
|
||||
request.priority_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::toggleDownloadIsPaused &request) {
|
||||
|
@ -147,7 +147,7 @@ class Td final : public Actor {
|
||||
unique_ptr<CountryInfoManager> country_info_manager_;
|
||||
ActorOwn<CountryInfoManager> country_info_manager_actor_;
|
||||
unique_ptr<DownloadManager> download_manager_;
|
||||
ActorOwn<DownloadManager> download_manger_actor_;
|
||||
ActorOwn<DownloadManager> download_manager_actor_;
|
||||
unique_ptr<FileManager> file_manager_;
|
||||
ActorOwn<FileManager> file_manager_actor_;
|
||||
unique_ptr<FileReferenceManager> file_reference_manager_;
|
||||
|
Loading…
Reference in New Issue
Block a user