Repair sticker set thumbnail if changed.

GitOrigin-RevId: 1b0e2e997338d85249e6eee877ab0483d9826342
This commit is contained in:
levlam 2019-07-30 18:43:29 +03:00
parent 089d73953c
commit 2fd851dfe2
6 changed files with 29 additions and 19 deletions

View File

@ -8907,7 +8907,7 @@ ContactsManager::User *ContactsManager::get_user(UserId user_id) {
}
}
void ContactsManager::reload_dialog(DialogId dialog_id, Promise<Unit> &&promise) {
void ContactsManager::reload_dialog_info(DialogId dialog_id, Promise<Unit> &&promise) {
switch (dialog_id.get_type()) {
case DialogType::User:
return reload_user(dialog_id.get_user_id(), std::move(promise));

View File

@ -351,7 +351,7 @@ class ContactsManager : public Actor {
bool have_min_user(UserId user_id) const;
bool have_user_force(UserId user_id);
void reload_dialog(DialogId dialog_id, Promise<Unit> &&promise);
void reload_dialog_info(DialogId dialog_id, Promise<Unit> &&promise);
static void send_get_me_query(Td *td, Promise<Unit> &&promise);
UserId get_me(Promise<Unit> &&promise);

View File

@ -340,13 +340,16 @@ void FileReferenceManager::reload_photo(PhotoSizeSource source, Promise<Unit> pr
switch (source.get_type()) {
case PhotoSizeSource::Type::DialogPhotoBig:
case PhotoSizeSource::Type::DialogPhotoSmall:
send_closure(G()->contacts_manager(), &ContactsManager::reload_dialog, source.dialog_photo().dialog_id,
send_closure(G()->contacts_manager(), &ContactsManager::reload_dialog_info, source.dialog_photo().dialog_id,
std::move(promise));
break;
case PhotoSizeSource::Type::StickerSetThumbnail:
//TODO
send_closure(G()->stickers_manager(), &StickersManager::reload_sticker_set,
source.sticker_set_thumbnail().sticker_set_id,
source.sticker_set_thumbnail().sticker_set_access_hash, std::move(promise));
break;
default:
promise.set_error(Status::Error("Unexpected PotoSizeSource type"));
promise.set_error(Status::Error("Unexpected PhotoSizeSource type"));
}
}

View File

@ -2434,10 +2434,10 @@ bool StickersManager::update_sticker_set_cache(const StickerSet *sticker_set, Pr
} else {
if (G()->unix_time() >= sticker_set->expires_at) {
if (td_->auth_manager_->is_bot()) {
reload_sticker_set(set_id, get_input_sticker_set(sticker_set), std::move(promise));
do_reload_sticker_set(set_id, get_input_sticker_set(sticker_set), std::move(promise));
return true;
} else {
reload_sticker_set(set_id, get_input_sticker_set(sticker_set), Auto());
do_reload_sticker_set(set_id, get_input_sticker_set(sticker_set), Auto());
}
}
}
@ -2449,7 +2449,7 @@ int64 StickersManager::get_sticker_set(int64 set_id, Promise<Unit> &&promise) {
const StickerSet *sticker_set = get_sticker_set(set_id);
if (sticker_set == nullptr) {
if (set_id == GREAT_MINDS_SET_ID) {
reload_sticker_set(set_id, make_tl_object<telegram_api::inputStickerSetID>(set_id, 0), std::move(promise));
do_reload_sticker_set(set_id, make_tl_object<telegram_api::inputStickerSetID>(set_id, 0), std::move(promise));
return 0;
}
@ -2472,7 +2472,7 @@ int64 StickersManager::search_sticker_set(const string &short_name_to_search, Pr
if (sticker_set == nullptr) {
auto set_to_load = make_tl_object<telegram_api::inputStickerSetShortName>(short_name);
reload_sticker_set(0, std::move(set_to_load), std::move(promise));
do_reload_sticker_set(0, std::move(set_to_load), std::move(promise));
return 0;
}
@ -2849,7 +2849,7 @@ void StickersManager::load_sticker_sets(vector<int64> &&sticker_set_ids, Promise
}));
} else {
LOG(INFO) << "Trying to load sticker set " << sticker_set_id << " with stickers from server";
reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto());
do_reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto());
}
}
}
@ -2885,7 +2885,7 @@ void StickersManager::load_sticker_sets_without_stickers(vector<int64> &&sticker
}));
} else {
LOG(INFO) << "Trying to load sticker set " << sticker_set_id << " from server";
reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto());
do_reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto());
}
}
}
@ -2910,7 +2910,7 @@ void StickersManager::on_load_sticker_set_from_database(int64 sticker_set_id, bo
CHECK(!sticker_set->load_without_stickers_requests.empty());
}
if (value.empty()) {
return reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto());
return do_reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto());
}
LOG(INFO) << "Successfully loaded sticker set " << sticker_set_id << " with" << (with_stickers ? "" : "out")
@ -2936,7 +2936,7 @@ void StickersManager::on_load_sticker_set_from_database(int64 sticker_set_id, bo
}
}
if (!sticker_set->is_thumbnail_reloaded) {
reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto());
do_reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto());
}
if (with_stickers && old_sticker_count < 5 && old_sticker_count < sticker_set->sticker_ids.size()) {
@ -2947,7 +2947,12 @@ void StickersManager::on_load_sticker_set_from_database(int64 sticker_set_id, bo
update_load_requests(sticker_set, with_stickers, Status::OK());
}
void StickersManager::reload_sticker_set(int64 sticker_set_id,
void StickersManager::reload_sticker_set(int64 sticker_set_id, int64 access_hash, Promise<Unit> &&promise) {
do_reload_sticker_set(sticker_set_id, make_tl_object<telegram_api::inputStickerSetID>(sticker_set_id, access_hash),
std::move(promise));
}
void StickersManager::do_reload_sticker_set(int64 sticker_set_id,
tl_object_ptr<telegram_api::InputStickerSet> &&input_sticker_set,
Promise<Unit> &&promise) const {
if (G()->close_flag()) {

View File

@ -201,6 +201,8 @@ class StickersManager : public Actor {
td_api::object_ptr<td_api::httpUrl> get_emoji_suggestions_url_result(int64 random_id);
void reload_sticker_set(int64 sticker_set_id, int64 access_hash, Promise<Unit> &&promise);
void reload_installed_sticker_sets(bool is_masks, bool force);
void reload_featured_sticker_sets(bool force);
@ -373,7 +375,7 @@ class StickersManager : public Actor {
void update_load_request(uint32 load_request_id, const Status &status);
void reload_sticker_set(int64 sticker_set_id, tl_object_ptr<telegram_api::InputStickerSet> &&input_sticker_set,
void do_reload_sticker_set(int64 sticker_set_id, tl_object_ptr<telegram_api::InputStickerSet> &&input_sticker_set,
Promise<Unit> &&promise) const;
static void read_featured_sticker_sets(void *td_void);

View File

@ -301,7 +301,7 @@ class FileView {
return node_->encryption_key_;
}
bool may_reload_photo() {
bool may_reload_photo() const {
if (!has_remote_location()) {
return false;
}