Add source to on_get_sticker_document.
This commit is contained in:
parent
9f138ba596
commit
f2d2a94ae3
@ -30,8 +30,9 @@ BusinessIntro::BusinessIntro(Td *td, telegram_api::object_ptr<telegram_api::busi
|
||||
}
|
||||
title_ = std::move(intro->title_);
|
||||
description_ = std::move(intro->description_);
|
||||
sticker_file_id_ =
|
||||
td->stickers_manager_->on_get_sticker_document(std::move(intro->sticker_), StickerFormat::Unknown).second;
|
||||
sticker_file_id_ = td->stickers_manager_
|
||||
->on_get_sticker_document(std::move(intro->sticker_), StickerFormat::Unknown, "BusinessIntro")
|
||||
.second;
|
||||
}
|
||||
|
||||
BusinessIntro::BusinessIntro(Td *td, td_api::object_ptr<td_api::inputBusinessStartPage> intro) {
|
||||
|
@ -874,31 +874,32 @@ void ReactionManager::on_get_available_reactions(
|
||||
reaction.title_ = std::move(available_reaction->title_);
|
||||
reaction.static_icon_ =
|
||||
td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(available_reaction->static_icon_), StickerFormat::Webp)
|
||||
.second;
|
||||
reaction.appear_animation_ =
|
||||
td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(available_reaction->appear_animation_), StickerFormat::Tgs)
|
||||
.second;
|
||||
reaction.select_animation_ =
|
||||
td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(available_reaction->select_animation_), StickerFormat::Tgs)
|
||||
.second;
|
||||
reaction.activate_animation_ =
|
||||
td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(available_reaction->activate_animation_), StickerFormat::Tgs)
|
||||
.second;
|
||||
reaction.effect_animation_ =
|
||||
td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(available_reaction->effect_animation_), StickerFormat::Tgs)
|
||||
.second;
|
||||
reaction.around_animation_ =
|
||||
td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(available_reaction->around_animation_), StickerFormat::Tgs)
|
||||
.second;
|
||||
reaction.center_animation_ =
|
||||
td_->stickers_manager_->on_get_sticker_document(std::move(available_reaction->center_icon_), StickerFormat::Tgs)
|
||||
->on_get_sticker_document(std::move(available_reaction->static_icon_), StickerFormat::Webp, "static_icon")
|
||||
.second;
|
||||
reaction.appear_animation_ = td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(available_reaction->appear_animation_),
|
||||
StickerFormat::Tgs, "appear_animation")
|
||||
.second;
|
||||
reaction.select_animation_ = td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(available_reaction->select_animation_),
|
||||
StickerFormat::Tgs, "select_animation")
|
||||
.second;
|
||||
reaction.activate_animation_ = td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(available_reaction->activate_animation_),
|
||||
StickerFormat::Tgs, "activate_animation")
|
||||
.second;
|
||||
reaction.effect_animation_ = td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(available_reaction->effect_animation_),
|
||||
StickerFormat::Tgs, "effect_animation")
|
||||
.second;
|
||||
reaction.around_animation_ = td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(available_reaction->around_animation_),
|
||||
StickerFormat::Tgs, "around_animation")
|
||||
.second;
|
||||
reaction.center_animation_ = td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(available_reaction->center_icon_),
|
||||
StickerFormat::Tgs, "center_animation")
|
||||
.second;
|
||||
|
||||
if (!reaction.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid " << reaction.reaction_type_;
|
||||
@ -1310,7 +1311,8 @@ void ReactionManager::on_get_message_effects(
|
||||
auto effects = telegram_api::move_object_as<telegram_api::messages_availableEffects>(message_effects);
|
||||
FlatHashMap<int64, FileId> stickers;
|
||||
for (auto &document : effects->documents_) {
|
||||
auto sticker = td_->stickers_manager_->on_get_sticker_document(std::move(document), StickerFormat::Unknown);
|
||||
auto sticker = td_->stickers_manager_->on_get_sticker_document(std::move(document), StickerFormat::Unknown,
|
||||
"on_get_message_effects");
|
||||
if (sticker.first != 0 && sticker.second.is_valid()) {
|
||||
stickers.emplace(sticker.first, sticker.second);
|
||||
} else {
|
||||
|
@ -3005,20 +3005,20 @@ bool StickersManager::has_webp_thumbnail(const vector<tl_object_ptr<telegram_api
|
||||
}
|
||||
|
||||
std::pair<int64, FileId> StickersManager::on_get_sticker_document(tl_object_ptr<telegram_api::Document> &&document_ptr,
|
||||
StickerFormat expected_format) {
|
||||
StickerFormat expected_format, const char *source) {
|
||||
if (document_ptr == nullptr) {
|
||||
return {};
|
||||
}
|
||||
int32 document_constructor_id = document_ptr->get_id();
|
||||
if (document_constructor_id == telegram_api::documentEmpty::ID) {
|
||||
LOG(ERROR) << "Empty sticker document received";
|
||||
LOG(ERROR) << "Empty sticker document received from " << source;
|
||||
return {};
|
||||
}
|
||||
CHECK(document_constructor_id == telegram_api::document::ID);
|
||||
auto document = move_tl_object_as<telegram_api::document>(document_ptr);
|
||||
|
||||
if (!DcId::is_valid(document->dc_id_)) {
|
||||
LOG(ERROR) << "Wrong dc_id = " << document->dc_id_ << " in document " << to_string(document);
|
||||
LOG(ERROR) << "Wrong dc_id = " << document->dc_id_ << " from " << source << " in document " << to_string(document);
|
||||
return {};
|
||||
}
|
||||
auto dc_id = DcId::internal(document->dc_id_);
|
||||
@ -3050,14 +3050,15 @@ std::pair<int64, FileId> StickersManager::on_get_sticker_document(tl_object_ptr<
|
||||
}
|
||||
if (sticker == nullptr && custom_emoji == nullptr) {
|
||||
if (document->mime_type_ != "application/x-bad-tgsticker") {
|
||||
LOG(ERROR) << "Have no attributeSticker in sticker " << to_string(document);
|
||||
LOG(ERROR) << "Have no attributeSticker from " << source << " in " << to_string(document);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
auto format = get_sticker_format_by_mime_type(document->mime_type_);
|
||||
if (format == StickerFormat::Unknown || (expected_format != StickerFormat::Unknown && format != expected_format)) {
|
||||
LOG(ERROR) << "Expected sticker of the type " << expected_format << ", but received of the type " << format;
|
||||
LOG(ERROR) << "Expected sticker of the type " << expected_format << ", but received of the type " << format
|
||||
<< " from " << source;
|
||||
return {};
|
||||
}
|
||||
int64 document_id = document->id_;
|
||||
@ -3808,7 +3809,7 @@ StickerSetId StickersManager::on_get_sticker_set_covered(tl_object_ptr<telegram_
|
||||
|
||||
auto &sticker_ids = sticker_set->sticker_ids_;
|
||||
|
||||
auto sticker_id = on_get_sticker_document(std::move(covered_set->cover_), StickerFormat::Unknown).second;
|
||||
auto sticker_id = on_get_sticker_document(std::move(covered_set->cover_), StickerFormat::Unknown, source).second;
|
||||
if (sticker_id.is_valid() && !td::contains(sticker_ids, sticker_id)) {
|
||||
sticker_ids.push_back(sticker_id);
|
||||
sticker_set->is_changed_ = true;
|
||||
@ -3832,7 +3833,7 @@ StickerSetId StickersManager::on_get_sticker_set_covered(tl_object_ptr<telegram_
|
||||
auto &sticker_ids = sticker_set->sticker_ids_;
|
||||
|
||||
for (auto &cover : multicovered_set->covers_) {
|
||||
auto sticker_id = on_get_sticker_document(std::move(cover), StickerFormat::Unknown).second;
|
||||
auto sticker_id = on_get_sticker_document(std::move(cover), StickerFormat::Unknown, source).second;
|
||||
if (sticker_id.is_valid() && !td::contains(sticker_ids, sticker_id)) {
|
||||
sticker_ids.push_back(sticker_id);
|
||||
sticker_set->is_changed_ = true;
|
||||
@ -3915,7 +3916,7 @@ StickerSetId StickersManager::on_get_messages_sticker_set(StickerSetId sticker_s
|
||||
s->premium_sticker_positions_.clear();
|
||||
bool is_bot = td_->auth_manager_->is_bot();
|
||||
for (auto &document_ptr : set->documents_) {
|
||||
auto sticker_id = on_get_sticker_document(std::move(document_ptr), StickerFormat::Unknown);
|
||||
auto sticker_id = on_get_sticker_document(std::move(document_ptr), StickerFormat::Unknown, source);
|
||||
if (!sticker_id.second.is_valid() || sticker_id.first == 0) {
|
||||
continue;
|
||||
}
|
||||
@ -4730,7 +4731,8 @@ void StickersManager::on_find_stickers_success(const string &emoji,
|
||||
|
||||
vector<FileId> sticker_ids;
|
||||
for (auto &sticker : received_stickers->stickers_) {
|
||||
FileId sticker_id = on_get_sticker_document(std::move(sticker), StickerFormat::Unknown).second;
|
||||
FileId sticker_id =
|
||||
on_get_sticker_document(std::move(sticker), StickerFormat::Unknown, "on_find_stickers_success").second;
|
||||
if (sticker_id.is_valid()) {
|
||||
sticker_ids.push_back(sticker_id);
|
||||
}
|
||||
@ -6404,7 +6406,7 @@ void StickersManager::on_get_custom_emoji_documents(
|
||||
continue;
|
||||
}
|
||||
|
||||
on_get_sticker_document(std::move(document), StickerFormat::Unknown);
|
||||
on_get_sticker_document(std::move(document), StickerFormat::Unknown, "on_get_custom_emoji_documents");
|
||||
}
|
||||
|
||||
promise.set_value(get_custom_emoji_stickers_object(custom_emoji_ids));
|
||||
@ -8938,7 +8940,8 @@ void StickersManager::on_get_recent_stickers(bool is_repair, bool is_attached,
|
||||
vector<FileId> recent_sticker_ids;
|
||||
recent_sticker_ids.reserve(stickers->stickers_.size());
|
||||
for (auto &document_ptr : stickers->stickers_) {
|
||||
auto sticker_id = on_get_sticker_document(std::move(document_ptr), StickerFormat::Unknown).second;
|
||||
auto sticker_id =
|
||||
on_get_sticker_document(std::move(document_ptr), StickerFormat::Unknown, "on_get_recent_stickers").second;
|
||||
if (!sticker_id.is_valid()) {
|
||||
continue;
|
||||
}
|
||||
@ -9332,7 +9335,8 @@ void StickersManager::on_get_favorite_stickers(
|
||||
vector<FileId> favorite_sticker_ids;
|
||||
favorite_sticker_ids.reserve(favorite_stickers->stickers_.size());
|
||||
for (auto &document_ptr : favorite_stickers->stickers_) {
|
||||
auto sticker_id = on_get_sticker_document(std::move(document_ptr), StickerFormat::Unknown).second;
|
||||
auto sticker_id =
|
||||
on_get_sticker_document(std::move(document_ptr), StickerFormat::Unknown, "on_get_favorite_stickers").second;
|
||||
if (!sticker_id.is_valid()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ class StickersManager final : public Actor {
|
||||
void reload_special_sticker_set_by_type(SpecialStickerSetType type, bool is_recursive = false);
|
||||
|
||||
std::pair<int64, FileId> on_get_sticker_document(tl_object_ptr<telegram_api::Document> &&document_ptr,
|
||||
StickerFormat expected_format);
|
||||
StickerFormat expected_format, const char *source);
|
||||
|
||||
void on_get_installed_sticker_sets(StickerType sticker_type,
|
||||
tl_object_ptr<telegram_api::messages_AllStickers> &&stickers_ptr);
|
||||
|
@ -623,8 +623,10 @@ WebPageId WebPagesManager::on_get_web_page(tl_object_ptr<telegram_api::WebPage>
|
||||
LOG(ERROR) << "Receive duplicate webPageAttributeStickerSet";
|
||||
}
|
||||
for (auto &sticker : attribute->stickers_) {
|
||||
auto sticker_id =
|
||||
td_->stickers_manager_->on_get_sticker_document(std::move(sticker), StickerFormat::Unknown).second;
|
||||
auto sticker_id = td_->stickers_manager_
|
||||
->on_get_sticker_document(std::move(sticker), StickerFormat::Unknown,
|
||||
"webPageAttributeStickerSet")
|
||||
.second;
|
||||
if (sticker_id.is_valid() && page->sticker_ids_.size() < 4) {
|
||||
page->sticker_ids_.push_back(sticker_id);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user