Add fileSourceAppConfig.

This commit is contained in:
levlam 2021-10-08 13:41:22 +03:00
parent 0259ee8262
commit f70498898b
5 changed files with 39 additions and 2 deletions

View File

@ -8,6 +8,7 @@
#include "td/telegram/AnimationsManager.h" #include "td/telegram/AnimationsManager.h"
#include "td/telegram/BackgroundManager.h" #include "td/telegram/BackgroundManager.h"
#include "td/telegram/ConfigManager.h"
#include "td/telegram/ContactsManager.h" #include "td/telegram/ContactsManager.h"
#include "td/telegram/files/FileManager.h" #include "td/telegram/files/FileManager.h"
#include "td/telegram/Global.h" #include "td/telegram/Global.h"
@ -58,6 +59,7 @@ fileSourceFavoriteStickers = FileSource; // repa
fileSourceBackground background_id:int64 access_hash:int64 = FileSource; // repaired with account.getWallPaper fileSourceBackground background_id:int64 access_hash:int64 = FileSource; // repaired with account.getWallPaper
fileSourceBasicGroupFull basic_group_id:int32 = FileSource; // repaired with messages.getFullChat fileSourceBasicGroupFull basic_group_id:int32 = FileSource; // repaired with messages.getFullChat
fileSourceSupergroupFull supergroup_id:int32 = FileSource; // repaired with messages.getFullChannel fileSourceSupergroupFull supergroup_id:int32 = FileSource; // repaired with messages.getFullChannel
fileSourceAppConfig = FileSource; // repaired with help.getAppConfig, not reliable
*/ */
FileSourceId FileReferenceManager::get_current_file_source_id() const { FileSourceId FileReferenceManager::get_current_file_source_id() const {
@ -117,6 +119,11 @@ FileSourceId FileReferenceManager::create_channel_full_file_source(ChannelId cha
return add_file_source_id(source, PSLICE() << "full " << channel_id); return add_file_source_id(source, PSLICE() << "full " << channel_id);
} }
FileSourceId FileReferenceManager::create_app_config_file_source() {
FileSourceAppConfig source;
return add_file_source_id(source, "app config");
}
bool FileReferenceManager::add_file_source(NodeId node_id, FileSourceId file_source_id) { bool FileReferenceManager::add_file_source(NodeId node_id, FileSourceId file_source_id) {
bool is_added = nodes_[node_id].file_source_ids.add(file_source_id); bool is_added = nodes_[node_id].file_source_ids.add(file_source_id);
VLOG(file_references) << "Add " << (is_added ? "new" : "old") << ' ' << file_source_id << " for file " << node_id; VLOG(file_references) << "Add " << (is_added ? "new" : "old") << ' ' << file_source_id << " for file " << node_id;
@ -290,6 +297,9 @@ void FileReferenceManager::send_query(Destination dest, FileSourceId file_source
[&](const FileSourceChannelFull &source) { [&](const FileSourceChannelFull &source) {
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_channel_full, source.channel_id, send_closure_later(G()->contacts_manager(), &ContactsManager::reload_channel_full, source.channel_id,
std::move(promise), "repair file reference"); std::move(promise), "repair file reference");
},
[&](const FileSourceAppConfig &source) {
send_closure_later(G()->config_manager(), &ConfigManager::reget_app_config, std::move(promise));
})); }));
} }

View File

@ -51,6 +51,7 @@ class FileReferenceManager final : public Actor {
FileSourceId create_background_file_source(BackgroundId background_id, int64 access_hash); FileSourceId create_background_file_source(BackgroundId background_id, int64 access_hash);
FileSourceId create_chat_full_file_source(ChatId chat_id); FileSourceId create_chat_full_file_source(ChatId chat_id);
FileSourceId create_channel_full_file_source(ChannelId channel_id); FileSourceId create_channel_full_file_source(ChannelId channel_id);
FileSourceId create_app_config_file_source();
using NodeId = FileId; using NodeId = FileId;
void repair_file_reference(NodeId node_id, Promise<> promise); void repair_file_reference(NodeId node_id, Promise<> promise);
@ -132,12 +133,15 @@ class FileReferenceManager final : public Actor {
struct FileSourceChannelFull { struct FileSourceChannelFull {
ChannelId channel_id; ChannelId channel_id;
}; };
struct FileSourceAppConfig {
// empty
};
// append only // append only
using FileSource = using FileSource =
Variant<FileSourceMessage, FileSourceUserPhoto, FileSourceChatPhoto, FileSourceChannelPhoto, FileSourceWallpapers, Variant<FileSourceMessage, FileSourceUserPhoto, FileSourceChatPhoto, FileSourceChannelPhoto, FileSourceWallpapers,
FileSourceWebPage, FileSourceSavedAnimations, FileSourceRecentStickers, FileSourceFavoriteStickers, FileSourceWebPage, FileSourceSavedAnimations, FileSourceRecentStickers, FileSourceFavoriteStickers,
FileSourceBackground, FileSourceChatFull, FileSourceChannelFull>; FileSourceBackground, FileSourceChatFull, FileSourceChannelFull, FileSourceAppConfig>;
vector<FileSource> file_sources_; vector<FileSource> file_sources_;
int64 query_generation_{0}; int64 query_generation_{0};

View File

@ -49,7 +49,8 @@ void FileReferenceManager::store_file_source(FileSourceId file_source_id, Storer
td::store(source.access_hash, storer); td::store(source.access_hash, storer);
}, },
[&](const FileSourceChatFull &source) { td::store(source.chat_id, storer); }, [&](const FileSourceChatFull &source) { td::store(source.chat_id, storer); },
[&](const FileSourceChannelFull &source) { td::store(source.channel_id, storer); })); [&](const FileSourceChannelFull &source) { td::store(source.channel_id, storer); },
[&](const FileSourceAppConfig &source) {}));
} }
template <class ParserT> template <class ParserT>
@ -111,6 +112,8 @@ FileSourceId FileReferenceManager::parse_file_source(Td *td, ParserT &parser) {
td::parse(channel_id, parser); td::parse(channel_id, parser);
return td->contacts_manager_->get_channel_full_file_source_id(channel_id); return td->contacts_manager_->get_channel_full_file_source_id(channel_id);
} }
case 12:
return td->stickers_manager_->get_app_config_file_source_id();
default: default:
parser.set_error("Invalid type in FileSource"); parser.set_error("Invalid type in FileSource");
return FileSourceId(); return FileSourceId();

View File

@ -4096,7 +4096,13 @@ void StickersManager::on_update_emoji_sounds() {
LOG(INFO) << "Change emoji sounds to " << emoji_sounds_str; LOG(INFO) << "Change emoji sounds to " << emoji_sounds_str;
emoji_sounds_str_ = std::move(emoji_sounds_str); emoji_sounds_str_ = std::move(emoji_sounds_str);
vector<FileId> old_file_ids;
for (auto &emoji_sound : emoji_sounds_) {
old_file_ids.push_back(emoji_sound.second);
}
emoji_sounds_.clear(); emoji_sounds_.clear();
vector<FileId> new_file_ids;
auto sounds = full_split(Slice(emoji_sounds_str_), ','); auto sounds = full_split(Slice(emoji_sounds_str_), ',');
CHECK(sounds.size() % 2 == 0); CHECK(sounds.size() % 2 == 0);
for (size_t i = 0; i < sounds.size(); i += 2) { for (size_t i = 0; i < sounds.size(); i += 2) {
@ -4114,7 +4120,10 @@ void StickersManager::on_update_emoji_sounds() {
FileLocationSource::FromServer, DialogId(), 0, expected_size, std::move(suggested_file_name)); FileLocationSource::FromServer, DialogId(), 0, expected_size, std::move(suggested_file_name));
CHECK(file_id.is_valid()); CHECK(file_id.is_valid());
emoji_sounds_.emplace(remove_fitzpatrick_modifier(sounds[i]).str(), file_id); emoji_sounds_.emplace(remove_fitzpatrick_modifier(sounds[i]).str(), file_id);
new_file_ids.push_back(file_id);
} }
td_->file_manager_->change_files_source(get_app_config_file_source_id(), old_file_ids, new_file_ids);
try_update_animated_emoji_messages(); try_update_animated_emoji_messages();
} }
@ -6610,6 +6619,13 @@ int64 StickersManager::get_favorite_stickers_hash() const {
return get_recent_stickers_hash(favorite_sticker_ids_); return get_recent_stickers_hash(favorite_sticker_ids_);
} }
FileSourceId StickersManager::get_app_config_file_source_id() {
if (!app_config_file_source_id_.is_valid()) {
app_config_file_source_id_ = td_->file_reference_manager_->create_app_config_file_source();
}
return app_config_file_source_id_;
}
FileSourceId StickersManager::get_favorite_stickers_file_source_id() { FileSourceId StickersManager::get_favorite_stickers_file_source_id() {
if (!favorite_stickers_file_source_id_.is_valid()) { if (!favorite_stickers_file_source_id_.is_valid()) {
favorite_stickers_file_source_id_ = td_->file_reference_manager_->create_favorite_stickers_file_source(); favorite_stickers_file_source_id_ = td_->file_reference_manager_->create_favorite_stickers_file_source();

View File

@ -241,6 +241,8 @@ class StickersManager final : public Actor {
void on_get_favorite_stickers_failed(bool is_repair, Status error); void on_get_favorite_stickers_failed(bool is_repair, Status error);
FileSourceId get_app_config_file_source_id();
FileSourceId get_favorite_stickers_file_source_id(); FileSourceId get_favorite_stickers_file_source_id();
vector<FileId> get_favorite_stickers(Promise<Unit> &&promise); vector<FileId> get_favorite_stickers(Promise<Unit> &&promise);
@ -747,6 +749,8 @@ class StickersManager final : public Actor {
vector<FileId> favorite_sticker_file_ids_; vector<FileId> favorite_sticker_file_ids_;
FileSourceId favorite_stickers_file_source_id_; FileSourceId favorite_stickers_file_source_id_;
FileSourceId app_config_file_source_id_;
vector<StickerSetId> archived_sticker_set_ids_[2]; vector<StickerSetId> archived_sticker_set_ids_[2];
int32 total_archived_sticker_set_count_[2] = {-1, -1}; int32 total_archived_sticker_set_count_[2] = {-1, -1};