Use get_document if possible.
This commit is contained in:
parent
98afc516dc
commit
8ec29b019a
@ -148,9 +148,9 @@ void AnimationsManager::tear_down() {
|
||||
}
|
||||
|
||||
int32 AnimationsManager::get_animation_duration(FileId file_id) const {
|
||||
auto it = animations_.find(file_id);
|
||||
CHECK(it != animations_.end());
|
||||
return it->second->duration;
|
||||
const auto *animation = get_animation(file_id);
|
||||
CHECK(animation != nullptr);
|
||||
return animation->duration;
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::animation> AnimationsManager::get_animation_object(FileId file_id) const {
|
||||
@ -158,9 +158,7 @@ tl_object_ptr<td_api::animation> AnimationsManager::get_animation_object(FileId
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto it = animations_.find(file_id);
|
||||
CHECK(it != animations_.end());
|
||||
auto animation = it->second.get();
|
||||
auto animation = get_animation(file_id);
|
||||
CHECK(animation != nullptr);
|
||||
auto thumbnail =
|
||||
animation->animated_thumbnail.file_id.is_valid()
|
||||
|
@ -19,9 +19,8 @@ namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void AnimationsManager::store_animation(FileId file_id, StorerT &storer) const {
|
||||
auto it = animations_.find(file_id);
|
||||
CHECK(it != animations_.end());
|
||||
const Animation *animation = it->second.get();
|
||||
const Animation *animation = get_animation(file_id);
|
||||
CHECK(animation != nullptr);
|
||||
bool has_animated_thumbnail = animation->animated_thumbnail.file_id.is_valid();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(animation->has_stickers);
|
||||
|
@ -29,11 +29,11 @@ AudiosManager::~AudiosManager() {
|
||||
}
|
||||
|
||||
int32 AudiosManager::get_audio_duration(FileId file_id) const {
|
||||
auto it = audios_.find(file_id);
|
||||
if (it == audios_.end()) {
|
||||
const auto *audio = get_audio(file_id);
|
||||
if (audio == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return it->second->duration;
|
||||
return audio->duration;
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::audio> AudiosManager::get_audio_object(FileId file_id) const {
|
||||
@ -41,9 +41,7 @@ tl_object_ptr<td_api::audio> AudiosManager::get_audio_object(FileId file_id) con
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto it = audios_.find(file_id);
|
||||
CHECK(it != audios_.end());
|
||||
auto audio = it->second.get();
|
||||
auto audio = get_audio(file_id);
|
||||
CHECK(audio != nullptr);
|
||||
|
||||
td_api::object_ptr<td_api::file> album_cover_file;
|
||||
@ -65,9 +63,7 @@ td_api::object_ptr<td_api::notificationSound> AudiosManager::get_notification_so
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto it = audios_.find(file_id);
|
||||
CHECK(it != audios_.end());
|
||||
auto audio = it->second.get();
|
||||
auto audio = get_audio(file_id);
|
||||
CHECK(audio != nullptr);
|
||||
auto file_view = td_->file_manager_->get_file_view(file_id);
|
||||
CHECK(!file_view.empty());
|
||||
|
@ -19,9 +19,8 @@ namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void AudiosManager::store_audio(FileId file_id, StorerT &storer) const {
|
||||
auto it = audios_.find(file_id);
|
||||
CHECK(it != audios_.end());
|
||||
const Audio *audio = it->second.get();
|
||||
const Audio *audio = get_audio(file_id);
|
||||
CHECK(audio != nullptr);
|
||||
bool has_file_name = !audio->file_name.empty();
|
||||
bool has_mime_type = !audio->mime_type.empty();
|
||||
bool has_duration = audio->duration != 0;
|
||||
|
@ -59,9 +59,7 @@ tl_object_ptr<td_api::document> DocumentsManager::get_document_object(FileId fil
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto it = documents_.find(file_id);
|
||||
CHECK(it != documents_.end());
|
||||
auto document = it->second.get();
|
||||
auto document = get_document(file_id);
|
||||
CHECK(document != nullptr);
|
||||
return make_tl_object<td_api::document>(
|
||||
document->file_name, document->mime_type, get_minithumbnail_object(document->minithumbnail),
|
||||
|
@ -19,10 +19,8 @@ namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void DocumentsManager::store_document(FileId file_id, StorerT &storer) const {
|
||||
LOG(DEBUG) << "Store document " << file_id;
|
||||
auto it = documents_.find(file_id);
|
||||
CHECK(it != documents_.end());
|
||||
const GeneralDocument *document = it->second.get();
|
||||
const GeneralDocument *document = get_document(file_id);
|
||||
CHECK(document != nullptr);
|
||||
store(document->file_name, storer);
|
||||
store(document->mime_type, storer);
|
||||
store(document->minithumbnail, storer);
|
||||
@ -40,7 +38,6 @@ FileId DocumentsManager::parse_document(ParserT &parser) {
|
||||
}
|
||||
parse(document->thumbnail, parser);
|
||||
parse(document->file_id, parser);
|
||||
LOG(DEBUG) << "Parsed document " << document->file_id;
|
||||
if (parser.get_error() != nullptr || !document->file_id.is_valid()) {
|
||||
return FileId();
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ VideoNotesManager::~VideoNotesManager() {
|
||||
}
|
||||
|
||||
int32 VideoNotesManager::get_video_note_duration(FileId file_id) const {
|
||||
auto it = video_notes_.find(file_id);
|
||||
CHECK(it != video_notes_.end());
|
||||
return it->second->duration;
|
||||
auto video_note = get_video_note(file_id);
|
||||
CHECK(video_note != nullptr);
|
||||
return video_note->duration;
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::videoNote> VideoNotesManager::get_video_note_object(FileId file_id) const {
|
||||
@ -37,9 +37,7 @@ tl_object_ptr<td_api::videoNote> VideoNotesManager::get_video_note_object(FileId
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto it = video_notes_.find(file_id);
|
||||
CHECK(it != video_notes_.end());
|
||||
auto video_note = it->second.get();
|
||||
auto video_note = get_video_note(file_id);
|
||||
return make_tl_object<td_api::videoNote>(
|
||||
video_note->duration, video_note->dimensions.width, get_minithumbnail_object(video_note->minithumbnail),
|
||||
get_thumbnail_object(td_->file_manager_.get(), video_note->thumbnail, PhotoFormat::Jpeg),
|
||||
|
@ -19,9 +19,8 @@ namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void VideoNotesManager::store_video_note(FileId file_id, StorerT &storer) const {
|
||||
auto it = video_notes_.find(file_id);
|
||||
CHECK(it != video_notes_.end());
|
||||
const VideoNote *video_note = it->second.get();
|
||||
const VideoNote *video_note = get_video_note(file_id);
|
||||
CHECK(video_note != nullptr);
|
||||
store(video_note->duration, storer);
|
||||
store(video_note->dimensions, storer);
|
||||
store(video_note->minithumbnail, storer);
|
||||
|
@ -28,9 +28,9 @@ VideosManager::~VideosManager() {
|
||||
}
|
||||
|
||||
int32 VideosManager::get_video_duration(FileId file_id) const {
|
||||
auto it = videos_.find(file_id);
|
||||
CHECK(it != videos_.end());
|
||||
return it->second->duration;
|
||||
auto video = get_video(file_id);
|
||||
CHECK(video != nullptr);
|
||||
return video->duration;
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::video> VideosManager::get_video_object(FileId file_id) const {
|
||||
@ -38,9 +38,7 @@ tl_object_ptr<td_api::video> VideosManager::get_video_object(FileId file_id) con
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto it = videos_.find(file_id);
|
||||
CHECK(it != videos_.end());
|
||||
auto video = it->second.get();
|
||||
auto video = get_video(file_id);
|
||||
CHECK(video != nullptr);
|
||||
auto thumbnail = video->animated_thumbnail.file_id.is_valid()
|
||||
? get_thumbnail_object(td_->file_manager_.get(), video->animated_thumbnail, PhotoFormat::Mpeg4)
|
||||
|
@ -19,9 +19,8 @@ namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void VideosManager::store_video(FileId file_id, StorerT &storer) const {
|
||||
auto it = videos_.find(file_id);
|
||||
CHECK(it != videos_.end());
|
||||
const Video *video = it->second.get();
|
||||
const Video *video = get_video(file_id);
|
||||
CHECK(video != nullptr);
|
||||
bool has_animated_thumbnail = video->animated_thumbnail.file_id.is_valid();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(video->has_stickers);
|
||||
|
@ -122,11 +122,11 @@ void VoiceNotesManager::on_voice_note_transcription_timeout_callback(void *voice
|
||||
}
|
||||
|
||||
int32 VoiceNotesManager::get_voice_note_duration(FileId file_id) const {
|
||||
auto it = voice_notes_.find(file_id);
|
||||
if (it == voice_notes_.end()) {
|
||||
auto voice_note = get_voice_note(file_id);
|
||||
if (voice_note == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return it->second->duration;
|
||||
return voice_note->duration;
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::voiceNote> VoiceNotesManager::get_voice_note_object(FileId file_id) const {
|
||||
@ -134,9 +134,7 @@ tl_object_ptr<td_api::voiceNote> VoiceNotesManager::get_voice_note_object(FileId
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto it = voice_notes_.find(file_id);
|
||||
CHECK(it != voice_notes_.end());
|
||||
auto voice_note = it->second.get();
|
||||
auto voice_note = get_voice_note(file_id);
|
||||
CHECK(voice_note != nullptr);
|
||||
|
||||
auto speech_recognition_result = [this, voice_note]() -> td_api::object_ptr<td_api::SpeechRecognitionResult> {
|
||||
|
@ -18,9 +18,8 @@ namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void VoiceNotesManager::store_voice_note(FileId file_id, StorerT &storer) const {
|
||||
auto it = voice_notes_.find(file_id);
|
||||
CHECK(it != voice_notes_.end());
|
||||
const VoiceNote *voice_note = it->second.get();
|
||||
const VoiceNote *voice_note = get_voice_note(file_id);
|
||||
CHECK(voice_note != nullptr);
|
||||
bool has_mime_type = !voice_note->mime_type.empty();
|
||||
bool has_duration = voice_note->duration != 0;
|
||||
bool has_waveform = !voice_note->waveform.empty();
|
||||
|
Loading…
Reference in New Issue
Block a user