Removed checks
This commit is contained in:
parent
1285fe088b
commit
35fa5cd785
@ -78,7 +78,9 @@ class SaveGifQuery : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void send(FileId file_id, tl_object_ptr<telegram_api::inputDocument> &&input_document, bool unsave) {
|
void send(FileId file_id, tl_object_ptr<telegram_api::inputDocument> &&input_document, bool unsave) {
|
||||||
CHECK(input_document != nullptr);
|
if (input_document == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
CHECK(file_id.is_valid());
|
CHECK(file_id.is_valid());
|
||||||
file_id_ = file_id;
|
file_id_ = file_id;
|
||||||
file_reference_ = input_document->file_reference_.as_slice().str();
|
file_reference_ = input_document->file_reference_.as_slice().str();
|
||||||
@ -157,6 +159,9 @@ tl_object_ptr<td_api::animation> AnimationsManager::get_animation_object(FileId
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto &animation = animations_[file_id];
|
auto &animation = animations_[file_id];
|
||||||
|
if (animation == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
LOG_CHECK(animation != nullptr) << source << " " << file_id << " "
|
LOG_CHECK(animation != nullptr) << source << " " << file_id << " "
|
||||||
<< static_cast<int32>(td_->file_manager_->get_file_view(file_id).get_type());
|
<< static_cast<int32>(td_->file_manager_->get_file_view(file_id).get_type());
|
||||||
// TODO can we make that function const?
|
// TODO can we make that function const?
|
||||||
@ -229,13 +234,17 @@ const AnimationsManager::Animation *AnimationsManager::get_animation(FileId file
|
|||||||
|
|
||||||
FileId AnimationsManager::get_animation_thumbnail_file_id(FileId file_id) const {
|
FileId AnimationsManager::get_animation_thumbnail_file_id(FileId file_id) const {
|
||||||
auto animation = get_animation(file_id);
|
auto animation = get_animation(file_id);
|
||||||
CHECK(animation != nullptr);
|
if (animation == nullptr) {
|
||||||
|
return FileId();
|
||||||
|
}
|
||||||
return animation->thumbnail.file_id;
|
return animation->thumbnail.file_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationsManager::delete_animation_thumbnail(FileId file_id) {
|
void AnimationsManager::delete_animation_thumbnail(FileId file_id) {
|
||||||
auto &animation = animations_[file_id];
|
auto &animation = animations_[file_id];
|
||||||
CHECK(animation != nullptr);
|
if (animation == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
animation->thumbnail = PhotoSize();
|
animation->thumbnail = PhotoSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +328,9 @@ tl_object_ptr<telegram_api::InputMedia> AnimationsManager::get_input_media(
|
|||||||
|
|
||||||
if (input_file != nullptr) {
|
if (input_file != nullptr) {
|
||||||
const Animation *animation = get_animation(file_id);
|
const Animation *animation = get_animation(file_id);
|
||||||
CHECK(animation != nullptr);
|
if (animation == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
vector<tl_object_ptr<telegram_api::DocumentAttribute>> attributes;
|
vector<tl_object_ptr<telegram_api::DocumentAttribute>> attributes;
|
||||||
if (!animation->file_name.empty()) {
|
if (!animation->file_name.empty()) {
|
||||||
@ -356,7 +367,9 @@ SecretInputMedia AnimationsManager::get_secret_input_media(FileId animation_file
|
|||||||
const string &caption, BufferSlice thumbnail,
|
const string &caption, BufferSlice thumbnail,
|
||||||
int32 layer) const {
|
int32 layer) const {
|
||||||
auto *animation = get_animation(animation_file_id);
|
auto *animation = get_animation(animation_file_id);
|
||||||
CHECK(animation != nullptr);
|
if (animation == nullptr) {
|
||||||
|
return SecretInputMedia{};
|
||||||
|
}
|
||||||
auto file_view = td_->file_manager_->get_file_view(animation_file_id);
|
auto file_view = td_->file_manager_->get_file_view(animation_file_id);
|
||||||
auto &encryption_key = file_view.encryption_key();
|
auto &encryption_key = file_view.encryption_key();
|
||||||
if (!file_view.is_encrypted_secret() || encryption_key.empty()) {
|
if (!file_view.is_encrypted_secret() || encryption_key.empty()) {
|
||||||
@ -604,7 +617,9 @@ int32 AnimationsManager::get_saved_animations_hash(const char *source) const {
|
|||||||
numbers.reserve(saved_animation_ids_.size() * 2);
|
numbers.reserve(saved_animation_ids_.size() * 2);
|
||||||
for (auto animation_id : saved_animation_ids_) {
|
for (auto animation_id : saved_animation_ids_) {
|
||||||
auto animation = get_animation(animation_id);
|
auto animation = get_animation(animation_id);
|
||||||
CHECK(animation != nullptr);
|
if (animation == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
auto file_view = td_->file_manager_->get_file_view(animation_id);
|
auto file_view = td_->file_manager_->get_file_view(animation_id);
|
||||||
CHECK(file_view.has_remote_location());
|
CHECK(file_view.has_remote_location());
|
||||||
if (!file_view.remote_location().is_document()) {
|
if (!file_view.remote_location().is_document()) {
|
||||||
@ -807,7 +822,9 @@ FileSourceId AnimationsManager::get_saved_animations_file_source_id() {
|
|||||||
|
|
||||||
string AnimationsManager::get_animation_search_text(FileId file_id) const {
|
string AnimationsManager::get_animation_search_text(FileId file_id) const {
|
||||||
auto animation = get_animation(file_id);
|
auto animation = get_animation(file_id);
|
||||||
CHECK(animation != nullptr);
|
if (animation == nullptr) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return animation->file_name;
|
return animation->file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,19 +157,25 @@ bool AudiosManager::merge_audios(FileId new_id, FileId old_id, bool can_delete_o
|
|||||||
|
|
||||||
string AudiosManager::get_audio_search_text(FileId file_id) const {
|
string AudiosManager::get_audio_search_text(FileId file_id) const {
|
||||||
auto audio = get_audio(file_id);
|
auto audio = get_audio(file_id);
|
||||||
CHECK(audio != nullptr);
|
if (audio == nullptr) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return PSTRING() << audio->file_name << " " << audio->title << " " << audio->performer;
|
return PSTRING() << audio->file_name << " " << audio->title << " " << audio->performer;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileId AudiosManager::get_audio_thumbnail_file_id(FileId file_id) const {
|
FileId AudiosManager::get_audio_thumbnail_file_id(FileId file_id) const {
|
||||||
auto audio = get_audio(file_id);
|
auto audio = get_audio(file_id);
|
||||||
CHECK(audio != nullptr);
|
if (audio == nullptr) {
|
||||||
|
return FileId();
|
||||||
|
}
|
||||||
return audio->thumbnail.file_id;
|
return audio->thumbnail.file_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudiosManager::delete_audio_thumbnail(FileId file_id) {
|
void AudiosManager::delete_audio_thumbnail(FileId file_id) {
|
||||||
auto &audio = audios_[file_id];
|
auto &audio = audios_[file_id];
|
||||||
CHECK(audio != nullptr);
|
if (audio == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
audio->thumbnail = PhotoSize();
|
audio->thumbnail = PhotoSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +197,9 @@ SecretInputMedia AudiosManager::get_secret_input_media(FileId audio_file_id,
|
|||||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
||||||
const string &caption, BufferSlice thumbnail) const {
|
const string &caption, BufferSlice thumbnail) const {
|
||||||
auto *audio = get_audio(audio_file_id);
|
auto *audio = get_audio(audio_file_id);
|
||||||
CHECK(audio != nullptr);
|
if (audio == nullptr) {
|
||||||
|
return SecretInputMedia{};
|
||||||
|
}
|
||||||
auto file_view = td_->file_manager_->get_file_view(audio_file_id);
|
auto file_view = td_->file_manager_->get_file_view(audio_file_id);
|
||||||
auto &encryption_key = file_view.encryption_key();
|
auto &encryption_key = file_view.encryption_key();
|
||||||
if (!file_view.is_encrypted_secret() || encryption_key.empty()) {
|
if (!file_view.is_encrypted_secret() || encryption_key.empty()) {
|
||||||
@ -238,7 +246,9 @@ tl_object_ptr<telegram_api::InputMedia> AudiosManager::get_input_media(
|
|||||||
|
|
||||||
if (input_file != nullptr) {
|
if (input_file != nullptr) {
|
||||||
const Audio *audio = get_audio(file_id);
|
const Audio *audio = get_audio(file_id);
|
||||||
CHECK(audio != nullptr);
|
if (audio == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
vector<tl_object_ptr<telegram_api::DocumentAttribute>> attributes;
|
vector<tl_object_ptr<telegram_api::DocumentAttribute>> attributes;
|
||||||
attributes.push_back(make_tl_object<telegram_api::documentAttributeAudio>(
|
attributes.push_back(make_tl_object<telegram_api::documentAttributeAudio>(
|
||||||
|
@ -54,6 +54,9 @@ tl_object_ptr<td_api::document> DocumentsManager::get_document_object(FileId fil
|
|||||||
|
|
||||||
LOG(INFO) << "Return document " << file_id << " object";
|
LOG(INFO) << "Return document " << file_id << " object";
|
||||||
auto &document = documents_[file_id];
|
auto &document = documents_[file_id];
|
||||||
|
if (document == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
LOG_CHECK(document != nullptr) << tag("file_id", file_id);
|
LOG_CHECK(document != nullptr) << tag("file_id", file_id);
|
||||||
document->is_changed = false;
|
document->is_changed = false;
|
||||||
return make_tl_object<td_api::document>(document->file_name, document->mime_type,
|
return make_tl_object<td_api::document>(document->file_name, document->mime_type,
|
||||||
@ -516,7 +519,9 @@ SecretInputMedia DocumentsManager::get_secret_input_media(FileId document_file_i
|
|||||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
||||||
const string &caption, BufferSlice thumbnail) const {
|
const string &caption, BufferSlice thumbnail) const {
|
||||||
const GeneralDocument *document = get_document(document_file_id);
|
const GeneralDocument *document = get_document(document_file_id);
|
||||||
CHECK(document != nullptr);
|
if (document == nullptr) {
|
||||||
|
return SecretInputMedia{};
|
||||||
|
}
|
||||||
auto file_view = td_->file_manager_->get_file_view(document_file_id);
|
auto file_view = td_->file_manager_->get_file_view(document_file_id);
|
||||||
auto &encryption_key = file_view.encryption_key();
|
auto &encryption_key = file_view.encryption_key();
|
||||||
if (!file_view.is_encrypted_secret() || encryption_key.empty()) {
|
if (!file_view.is_encrypted_secret() || encryption_key.empty()) {
|
||||||
@ -559,7 +564,9 @@ tl_object_ptr<telegram_api::InputMedia> DocumentsManager::get_input_media(
|
|||||||
|
|
||||||
if (input_file != nullptr) {
|
if (input_file != nullptr) {
|
||||||
const GeneralDocument *document = get_document(file_id);
|
const GeneralDocument *document = get_document(file_id);
|
||||||
CHECK(document != nullptr);
|
if (document == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
vector<tl_object_ptr<telegram_api::DocumentAttribute>> attributes;
|
vector<tl_object_ptr<telegram_api::DocumentAttribute>> attributes;
|
||||||
if (document->file_name.size()) {
|
if (document->file_name.size()) {
|
||||||
@ -581,13 +588,17 @@ tl_object_ptr<telegram_api::InputMedia> DocumentsManager::get_input_media(
|
|||||||
|
|
||||||
FileId DocumentsManager::get_document_thumbnail_file_id(FileId file_id) const {
|
FileId DocumentsManager::get_document_thumbnail_file_id(FileId file_id) const {
|
||||||
auto document = get_document(file_id);
|
auto document = get_document(file_id);
|
||||||
CHECK(document != nullptr);
|
if (document == nullptr) {
|
||||||
|
return FileId();
|
||||||
|
}
|
||||||
return document->thumbnail.file_id;
|
return document->thumbnail.file_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentsManager::delete_document_thumbnail(FileId file_id) {
|
void DocumentsManager::delete_document_thumbnail(FileId file_id) {
|
||||||
auto &document = documents_[file_id];
|
auto &document = documents_[file_id];
|
||||||
CHECK(document != nullptr);
|
if (document == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
document->thumbnail = PhotoSize();
|
document->thumbnail = PhotoSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2697,7 +2697,9 @@ class GetGameHighScoresQuery : public Td::ResultHandler {
|
|||||||
random_id_ = random_id;
|
random_id_ = random_id;
|
||||||
|
|
||||||
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
||||||
CHECK(input_peer != nullptr);
|
if (input_peer == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CHECK(input_user != nullptr);
|
CHECK(input_user != nullptr);
|
||||||
send_query(G()->net_query_creator().create(telegram_api::messages_getGameHighScores(
|
send_query(G()->net_query_creator().create(telegram_api::messages_getGameHighScores(
|
||||||
@ -2881,7 +2883,9 @@ class SendScreenshotNotificationQuery : public Td::ResultHandler {
|
|||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
|
|
||||||
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
CHECK(input_peer != nullptr);
|
if (input_peer == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto query = G()->net_query_creator().create(
|
auto query = G()->net_query_creator().create(
|
||||||
telegram_api::messages_sendScreenshotNotification(std::move(input_peer), 0, random_id));
|
telegram_api::messages_sendScreenshotNotification(std::move(input_peer), 0, random_id));
|
||||||
@ -3039,7 +3043,9 @@ class DeleteChannelMessagesQuery : public Td::ResultHandler {
|
|||||||
|
|
||||||
query_count_++;
|
query_count_++;
|
||||||
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
|
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
|
||||||
CHECK(input_channel != nullptr);
|
if (input_channel == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
send_query(G()->net_query_creator().create(
|
send_query(G()->net_query_creator().create(
|
||||||
telegram_api::channels_deleteMessages(std::move(input_channel), std::move(slice))));
|
telegram_api::channels_deleteMessages(std::move(input_channel), std::move(slice))));
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ const VideoNotesManager::VideoNote *VideoNotesManager::get_video_note(FileId fil
|
|||||||
FileId VideoNotesManager::get_video_note_thumbnail_file_id(FileId file_id) const {
|
FileId VideoNotesManager::get_video_note_thumbnail_file_id(FileId file_id) const {
|
||||||
auto video_note = get_video_note(file_id);
|
auto video_note = get_video_note(file_id);
|
||||||
if (video_note == nullptr) {
|
if (video_note == nullptr) {
|
||||||
return nullptr;
|
return FileId();
|
||||||
}
|
}
|
||||||
return video_note->thumbnail.file_id;
|
return video_note->thumbnail.file_id;
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ FileId VideoNotesManager::get_video_note_thumbnail_file_id(FileId file_id) const
|
|||||||
void VideoNotesManager::delete_video_note_thumbnail(FileId file_id) {
|
void VideoNotesManager::delete_video_note_thumbnail(FileId file_id) {
|
||||||
auto &video_note = video_notes_[file_id];
|
auto &video_note = video_notes_[file_id];
|
||||||
if (video_note == nullptr) {
|
if (video_note == nullptr) {
|
||||||
return nullptr;
|
return;
|
||||||
}
|
}
|
||||||
video_note->thumbnail = PhotoSize();
|
video_note->thumbnail = PhotoSize();
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ void VideoNotesManager::delete_video_note_thumbnail(FileId file_id) {
|
|||||||
FileId VideoNotesManager::dup_video_note(FileId new_id, FileId old_id) {
|
FileId VideoNotesManager::dup_video_note(FileId new_id, FileId old_id) {
|
||||||
const VideoNote *old_video_note = get_video_note(old_id);
|
const VideoNote *old_video_note = get_video_note(old_id);
|
||||||
if (old_video_note == nullptr) {
|
if (old_video_note == nullptr) {
|
||||||
return nullptr;
|
return FileId();
|
||||||
}
|
}
|
||||||
auto &new_video_note = video_notes_[new_id];
|
auto &new_video_note = video_notes_[new_id];
|
||||||
CHECK(!new_video_note);
|
CHECK(!new_video_note);
|
||||||
|
@ -113,7 +113,7 @@ const VideosManager::Video *VideosManager::get_video(FileId file_id) const {
|
|||||||
FileId VideosManager::get_video_thumbnail_file_id(FileId file_id) const {
|
FileId VideosManager::get_video_thumbnail_file_id(FileId file_id) const {
|
||||||
auto video = get_video(file_id);
|
auto video = get_video(file_id);
|
||||||
if (video == nullptr) {
|
if (video == nullptr) {
|
||||||
return nullptr;
|
return FileId();
|
||||||
}
|
}
|
||||||
return video->thumbnail.file_id;
|
return video->thumbnail.file_id;
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ FileId VideosManager::get_video_thumbnail_file_id(FileId file_id) const {
|
|||||||
void VideosManager::delete_video_thumbnail(FileId file_id) {
|
void VideosManager::delete_video_thumbnail(FileId file_id) {
|
||||||
auto &video = videos_[file_id];
|
auto &video = videos_[file_id];
|
||||||
if (video == nullptr) {
|
if (video == nullptr) {
|
||||||
return nullptr;
|
return;
|
||||||
}
|
}
|
||||||
video->thumbnail = PhotoSize();
|
video->thumbnail = PhotoSize();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user