Add call_source to register_photo_size.

This commit is contained in:
levlam 2023-03-15 00:23:41 +03:00
parent 0dc9aac724
commit e5cb2fa963
5 changed files with 26 additions and 24 deletions

View File

@ -348,7 +348,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
premium_animation_file_id =
register_photo_size(td_->file_manager_.get(), PhotoSizeSource::thumbnail(FileType::Thumbnail, 'f'), id,
access_hash, file_reference, owner_dialog_id, video_size->size_, DcId::create(dc_id),
get_sticker_format_photo_format(sticker_format));
get_sticker_format_photo_format(sticker_format), "on_get_document");
}
}
}

View File

@ -54,12 +54,14 @@ ProfilePhoto get_profile_photo(FileManager *file_manager, UserId user_id, int64
result.is_personal = profile_photo->personal_;
result.id = profile_photo->photo_id_;
result.minithumbnail = profile_photo->stripped_thumb_.as_slice().str();
result.small_file_id = register_photo_size(
file_manager, PhotoSizeSource::dialog_photo(DialogId(user_id), user_access_hash, false), result.id,
0 /*access_hash*/, "" /*file_reference*/, DialogId(), 0 /*file_size*/, dc_id, PhotoFormat::Jpeg);
result.big_file_id = register_photo_size(
file_manager, PhotoSizeSource::dialog_photo(DialogId(user_id), user_access_hash, true), result.id,
0 /*access_hash*/, "" /*file_reference*/, DialogId(), 0 /*file_size*/, dc_id, PhotoFormat::Jpeg);
result.small_file_id =
register_photo_size(file_manager, PhotoSizeSource::dialog_photo(DialogId(user_id), user_access_hash, false),
result.id, 0 /*access_hash*/, "" /*file_reference*/, DialogId(), 0 /*file_size*/, dc_id,
PhotoFormat::Jpeg, "get_profile_photo small");
result.big_file_id =
register_photo_size(file_manager, PhotoSizeSource::dialog_photo(DialogId(user_id), user_access_hash, true),
result.id, 0 /*access_hash*/, "" /*file_reference*/, DialogId(), 0 /*file_size*/, dc_id,
PhotoFormat::Jpeg, "get_profile_photo big");
break;
}
default:
@ -107,12 +109,12 @@ DialogPhoto get_dialog_photo(FileManager *file_manager, DialogId dialog_id, int6
result.has_animation = chat_photo->has_video_;
result.is_personal = false;
result.minithumbnail = chat_photo->stripped_thumb_.as_slice().str();
result.small_file_id =
register_photo_size(file_manager, PhotoSizeSource::dialog_photo(dialog_id, dialog_access_hash, false),
chat_photo->photo_id_, 0, "", DialogId(), 0, dc_id, PhotoFormat::Jpeg);
result.big_file_id =
register_photo_size(file_manager, PhotoSizeSource::dialog_photo(dialog_id, dialog_access_hash, true),
chat_photo->photo_id_, 0, "", DialogId(), 0, dc_id, PhotoFormat::Jpeg);
result.small_file_id = register_photo_size(
file_manager, PhotoSizeSource::dialog_photo(dialog_id, dialog_access_hash, false), chat_photo->photo_id_, 0,
"", DialogId(), 0, dc_id, PhotoFormat::Jpeg, "get_dialog_photo small");
result.big_file_id = register_photo_size(
file_manager, PhotoSizeSource::dialog_photo(dialog_id, dialog_access_hash, true), chat_photo->photo_id_, 0,
"", DialogId(), 0, dc_id, PhotoFormat::Jpeg, "get_dialog_photo big");
break;
}

View File

@ -123,10 +123,10 @@ static StringBuilder &operator<<(StringBuilder &string_builder, PhotoFormat form
FileId register_photo_size(FileManager *file_manager, const PhotoSizeSource &source, int64 id, int64 access_hash,
string file_reference, DialogId owner_dialog_id, int32 file_size, DcId dc_id,
PhotoFormat format) {
LOG(DEBUG) << "Receive " << format << " photo " << id << " of type " << source.get_file_type("register_photo_size")
<< " from " << dc_id;
auto suggested_name = PSTRING() << source.get_unique_name(id, "register_photo_size") << '.' << format;
PhotoFormat format, const char *call_source) {
LOG(DEBUG) << "Receive " << format << " photo " << id << " of type " << source.get_file_type(call_source) << " from "
<< dc_id << " from " << call_source;
auto suggested_name = PSTRING() << source.get_unique_name(id, call_source) << '.' << format;
auto file_location_source = owner_dialog_id.get_type() == DialogType::SecretChat ? FileLocationSource::FromUser
: FileLocationSource::FromServer;
return file_manager->register_remote(
@ -250,7 +250,7 @@ Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSo
}
res.file_id = register_photo_size(file_manager, source, id, access_hash, std::move(file_reference), owner_dialog_id,
res.size, dc_id, format);
res.size, dc_id, format, "get_photo_size");
if (!content.empty()) {
file_manager->set_content(res.file_id, std::move(content));
@ -287,7 +287,7 @@ AnimationSize get_animation_size(Td *td, PhotoSizeSource source, int64 id, int64
}
result.file_id = register_photo_size(td->file_manager_.get(), source, id, access_hash, std::move(file_reference),
owner_dialog_id, result.size, dc_id, PhotoFormat::Mpeg4);
owner_dialog_id, result.size, dc_id, PhotoFormat::Mpeg4, "get_animation_size");
return result;
}

View File

@ -45,7 +45,7 @@ td_api::object_ptr<td_api::minithumbnail> get_minithumbnail_object(const string
FileId register_photo_size(FileManager *file_manager, const PhotoSizeSource &source, int64 id, int64 access_hash,
string file_reference, DialogId owner_dialog_id, int32 file_size, DcId dc_id,
PhotoFormat format);
PhotoFormat format, const char *call_source);
PhotoSize get_secret_thumbnail_photo_size(FileManager *file_manager, BufferSlice bytes, DialogId owner_dialog_id,
int32 width, int32 height);

View File

@ -3162,10 +3162,10 @@ std::pair<int64, FileId> StickersManager::on_get_sticker_document(tl_object_ptr<
auto video_size = move_tl_object_as<telegram_api::videoSize>(thumbnail_ptr);
if (video_size->type_ == "f") {
if (!premium_animation_file_id.is_valid()) {
premium_animation_file_id =
register_photo_size(td_->file_manager_.get(), PhotoSizeSource::thumbnail(FileType::Thumbnail, 'f'),
document_id, document->access_hash_, document->file_reference_.as_slice().str(),
DialogId(), video_size->size_, dc_id, get_sticker_format_photo_format(format));
premium_animation_file_id = register_photo_size(
td_->file_manager_.get(), PhotoSizeSource::thumbnail(FileType::Thumbnail, 'f'), document_id,
document->access_hash_, document->file_reference_.as_slice().str(), DialogId(), video_size->size_, dc_id,
get_sticker_format_photo_format(format), "on_get_sticker_document");
}
}
}