Do not create documents without file_id.
GitOrigin-RevId: c208baf37b108ffb256c3a39dee0459fc081f017
This commit is contained in:
parent
108dc0d4f8
commit
11c0fcc6ec
@ -169,6 +169,7 @@ tl_object_ptr<td_api::animation> AnimationsManager::get_animation_object(FileId
|
||||
|
||||
FileId AnimationsManager::on_get_animation(unique_ptr<Animation> new_animation, bool replace) {
|
||||
auto file_id = new_animation->file_id;
|
||||
CHECK(file_id.is_valid());
|
||||
auto &a = animations_[file_id];
|
||||
LOG(INFO) << (a == nullptr ? "Add" : (replace ? "Replace" : "Ignore")) << " animation " << file_id << " of size "
|
||||
<< new_animation->dimensions;
|
||||
|
@ -45,6 +45,9 @@ FileId AnimationsManager::parse_animation(ParserT &parser) {
|
||||
}
|
||||
parse(animation->thumbnail, parser);
|
||||
parse(animation->file_id, parser);
|
||||
if (parser.get_error() != nullptr || !animation->file_id.is_valid()) {
|
||||
return FileId();
|
||||
}
|
||||
return on_get_animation(std::move(animation), false);
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ tl_object_ptr<td_api::audio> AudiosManager::get_audio_object(FileId file_id) {
|
||||
|
||||
FileId AudiosManager::on_get_audio(unique_ptr<Audio> new_audio, bool replace) {
|
||||
auto file_id = new_audio->file_id;
|
||||
CHECK(file_id.is_valid());
|
||||
LOG(INFO) << "Receive audio " << file_id;
|
||||
auto &a = audios_[file_id];
|
||||
if (a == nullptr) {
|
||||
|
@ -45,6 +45,9 @@ FileId AudiosManager::parse_audio(ParserT &parser) {
|
||||
}
|
||||
parse(audio->thumbnail, parser);
|
||||
parse(audio->file_id, parser);
|
||||
if (parser.get_error() != nullptr || !audio->file_id.is_valid()) {
|
||||
return FileId();
|
||||
}
|
||||
return on_get_audio(std::move(audio), false);
|
||||
}
|
||||
|
||||
|
@ -437,6 +437,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
|
||||
FileId DocumentsManager::on_get_document(unique_ptr<GeneralDocument> new_document, bool replace) {
|
||||
auto file_id = new_document->file_id;
|
||||
CHECK(file_id.is_valid());
|
||||
LOG(INFO) << "Receive document " << file_id;
|
||||
auto &d = documents_[new_document->file_id];
|
||||
if (d == nullptr) {
|
||||
|
@ -41,6 +41,9 @@ 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();
|
||||
}
|
||||
return on_get_document(std::move(document), false);
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,9 @@ PollId PollManager::parse_poll(ParserT &parser) {
|
||||
vector<string> options;
|
||||
parse(question, parser);
|
||||
parse(options, parser);
|
||||
if (parser.get_error() != nullptr) {
|
||||
return PollId();
|
||||
}
|
||||
return create_poll(std::move(question), std::move(options));
|
||||
}
|
||||
|
||||
|
@ -1177,6 +1177,7 @@ tl_object_ptr<telegram_api::InputStickerSet> StickersManager::get_input_sticker_
|
||||
|
||||
FileId StickersManager::on_get_sticker(unique_ptr<Sticker> new_sticker, bool replace) {
|
||||
auto file_id = new_sticker->file_id;
|
||||
CHECK(file_id.is_valid());
|
||||
LOG(INFO) << "Receive sticker " << file_id;
|
||||
auto &s = stickers_[file_id];
|
||||
if (s == nullptr) {
|
||||
|
@ -105,6 +105,9 @@ FileId StickersManager::parse_sticker(bool in_sticker_set, ParserT &parser) {
|
||||
parse(sticker->y_shift, parser);
|
||||
parse(sticker->scale, parser);
|
||||
}
|
||||
if (parser.get_error() != nullptr || !sticker->file_id.is_valid()) {
|
||||
return FileId();
|
||||
}
|
||||
return on_get_sticker(std::move(sticker), false); // data in the database is always outdated
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@ tl_object_ptr<td_api::videoNote> VideoNotesManager::get_video_note_object(FileId
|
||||
|
||||
FileId VideoNotesManager::on_get_video_note(unique_ptr<VideoNote> new_video_note, bool replace) {
|
||||
auto file_id = new_video_note->file_id;
|
||||
CHECK(file_id.is_valid());
|
||||
LOG(INFO) << "Receive video note " << file_id;
|
||||
auto &v = video_notes_[file_id];
|
||||
if (v == nullptr) {
|
||||
|
@ -39,6 +39,9 @@ FileId VideoNotesManager::parse_video_note(ParserT &parser) {
|
||||
}
|
||||
parse(video_note->thumbnail, parser);
|
||||
parse(video_note->file_id, parser);
|
||||
if (parser.get_error() != nullptr || !video_note->file_id.is_valid()) {
|
||||
return FileId();
|
||||
}
|
||||
return on_get_video_note(std::move(video_note), false);
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@ tl_object_ptr<td_api::video> VideosManager::get_video_object(FileId file_id) {
|
||||
|
||||
FileId VideosManager::on_get_video(unique_ptr<Video> new_video, bool replace) {
|
||||
auto file_id = new_video->file_id;
|
||||
CHECK(file_id.is_valid());
|
||||
LOG(INFO) << "Receive video " << file_id;
|
||||
auto &v = videos_[file_id];
|
||||
if (v == nullptr) {
|
||||
|
@ -57,6 +57,9 @@ FileId VideosManager::parse_video(ParserT &parser) {
|
||||
if (video->has_stickers) {
|
||||
parse(video->sticker_file_ids, parser);
|
||||
}
|
||||
if (parser.get_error() != nullptr || !video->file_id.is_valid()) {
|
||||
return FileId();
|
||||
}
|
||||
return on_get_video(std::move(video), false);
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ tl_object_ptr<td_api::voiceNote> VoiceNotesManager::get_voice_note_object(FileId
|
||||
|
||||
FileId VoiceNotesManager::on_get_voice_note(unique_ptr<VoiceNote> new_voice_note, bool replace) {
|
||||
auto file_id = new_voice_note->file_id;
|
||||
CHECK(file_id.is_valid());
|
||||
LOG(INFO) << "Receive voice note " << file_id;
|
||||
auto &v = voice_notes_[file_id];
|
||||
if (v == nullptr) {
|
||||
|
@ -33,6 +33,9 @@ FileId VoiceNotesManager::parse_voice_note(ParserT &parser) {
|
||||
parse(voice_note->duration, parser);
|
||||
parse(voice_note->waveform, parser);
|
||||
parse(voice_note->file_id, parser);
|
||||
if (parser.get_error() != nullptr || !voice_note->file_id.is_valid()) {
|
||||
return FileId();
|
||||
}
|
||||
return on_get_voice_note(std::move(voice_note), false);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user