Add wallpapers file source for wallpapers registered by remote location.
GitOrigin-RevId: a0994ef92ef927d780acf6a79cfad5b424d93784
This commit is contained in:
parent
e01336c675
commit
d04a1a61cc
@ -64,7 +64,7 @@ FileSourceId FileReferenceManager::create_channel_photo_file_source(ChannelId ch
|
||||
}
|
||||
|
||||
FileSourceId FileReferenceManager::create_wallpapers_file_source() {
|
||||
FileSourceWebPage source;
|
||||
FileSourceWallpapers source;
|
||||
return add_file_source_id(source, "wallpapers");
|
||||
}
|
||||
|
||||
|
@ -4850,8 +4850,8 @@ void Td::on_request(uint64 id, const td_api::getFileDownloadedPrefixSize &reques
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getRemoteFile &request) {
|
||||
CLEAN_INPUT_STRING(request.remote_file_id_);
|
||||
auto r_file_id = file_manager_->from_persistent_id(
|
||||
request.remote_file_id_, request.file_type_ == nullptr ? FileType::Temp : from_td_api(*request.file_type_));
|
||||
auto file_type = request.file_type_ == nullptr ? FileType::Temp : from_td_api(*request.file_type_);
|
||||
auto r_file_id = file_manager_->from_persistent_id(request.remote_file_id_, file_type);
|
||||
if (r_file_id.is_error()) {
|
||||
send_closure(actor_id(this), &Td::send_error, id, r_file_id.move_as_error());
|
||||
} else {
|
||||
|
@ -127,6 +127,13 @@ void WallpaperManager::on_get_wallpapers(Result<vector<telegram_api::object_ptr<
|
||||
}
|
||||
}
|
||||
|
||||
void WallpaperManager::add_wallpapers_file_source(FileId file_id) {
|
||||
if (!wallpaper_source_id_.is_valid()) {
|
||||
wallpaper_source_id_ = td_->file_reference_manager_->create_wallpapers_file_source();
|
||||
}
|
||||
td_->file_manager_->add_file_source(file_id, wallpaper_source_id_);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::wallpapers> WallpaperManager::get_wallpapers_object() const {
|
||||
return td_api::make_object<td_api::wallpapers>(
|
||||
transform(wallpapers_, [file_manager = td_->file_manager_.get()](const Wallpaper &wallpaper) {
|
||||
|
@ -31,6 +31,8 @@ class WallpaperManager : public Actor {
|
||||
|
||||
td_api::object_ptr<td_api::wallpapers> get_wallpapers_object() const;
|
||||
|
||||
void add_wallpapers_file_source(FileId file_id);
|
||||
|
||||
private:
|
||||
void tear_down() override;
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/SecureStorage.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/WallpaperManager.h"
|
||||
|
||||
#include "td/utils/base64.h"
|
||||
#include "td/utils/format.h"
|
||||
@ -2199,7 +2200,12 @@ Result<FileId> FileManager::from_persistent_id_v2(Slice binary, FileType file_ty
|
||||
}
|
||||
FileData data;
|
||||
data.remote_ = RemoteFileLocation(std::move(remote_location));
|
||||
return register_file(std::move(data), FileLocationSource::FromUser, "from_persistent_id_v2", false).move_as_ok();
|
||||
auto file_id =
|
||||
register_file(std::move(data), FileLocationSource::FromUser, "from_persistent_id_v2", false).move_as_ok();
|
||||
if (real_file_type == FileType::Wallpaper && file_id.is_valid()) {
|
||||
send_closure(G()->wallpaper_manager(), &WallpaperManager::add_wallpapers_file_source, file_id);
|
||||
}
|
||||
return file_id;
|
||||
}
|
||||
|
||||
FileView FileManager::get_file_view(FileId file_id) const {
|
||||
|
Reference in New Issue
Block a user