From d580eb7818c4822e5db12acdbde36bb23e0bbba8 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 4 Dec 2018 21:18:07 +0300 Subject: [PATCH] Fix sending of secret_api::documentAttributeVideo. GitOrigin-RevId: b4247fe902cbf64dc12e67cc1f41f140b60db65a --- td/telegram/AnimationsManager.cpp | 13 ++++++++++--- td/telegram/AnimationsManager.h | 2 +- td/telegram/AudiosManager.cpp | 2 +- td/telegram/CallActor.cpp | 4 ++-- td/telegram/DocumentsManager.cpp | 2 +- td/telegram/MessageContent.cpp | 2 +- td/telegram/MessagesManager.cpp | 2 +- td/telegram/SecretChatActor.cpp | 4 ++-- td/telegram/SecretChatActor.h | 4 +++- td/telegram/VideoNotesManager.cpp | 4 ++-- td/telegram/VoiceNotesManager.cpp | 2 +- 11 files changed, 25 insertions(+), 16 deletions(-) diff --git a/td/telegram/AnimationsManager.cpp b/td/telegram/AnimationsManager.cpp index f0e81c67..05a4185c 100644 --- a/td/telegram/AnimationsManager.cpp +++ b/td/telegram/AnimationsManager.cpp @@ -13,6 +13,7 @@ #include "td/telegram/Global.h" #include "td/telegram/logevent/LogEvent.h" #include "td/telegram/misc.h" +#include "td/telegram/SecretChatActor.h" #include "td/telegram/Td.h" #include "td/telegram/secret_api.h" @@ -305,7 +306,8 @@ tl_object_ptr AnimationsManager::get_input_media( } SecretInputMedia AnimationsManager::get_secret_input_media(FileId animation_file_id, tl_object_ptr input_file, - const string &caption, BufferSlice thumbnail) const { + const string &caption, BufferSlice thumbnail, + int32 layer) const { auto *animation = get_animation(animation_file_id); CHECK(animation != nullptr); auto file_view = td_->file_manager_->get_file_view(animation_file_id); @@ -327,8 +329,13 @@ SecretInputMedia AnimationsManager::get_secret_input_media(FileId animation_file attributes.push_back(make_tl_object(animation->file_name)); } if (animation->duration != 0 && animation->mime_type == "video/mp4") { - attributes.push_back(make_tl_object( - animation->duration, animation->dimensions.width, animation->dimensions.height)); + if (layer >= SecretChatActor::VIDEO_NOTES_LAYER) { + attributes.push_back(make_tl_object( + 0, false, animation->duration, animation->dimensions.width, animation->dimensions.height)); + } else { + attributes.push_back(make_tl_object( + animation->duration, animation->dimensions.width, animation->dimensions.height)); + } } if (animation->dimensions.width != 0 && animation->dimensions.height != 0) { attributes.push_back(make_tl_object(animation->dimensions.width, diff --git a/td/telegram/AnimationsManager.h b/td/telegram/AnimationsManager.h index d8d3c6c1..41c02640 100644 --- a/td/telegram/AnimationsManager.h +++ b/td/telegram/AnimationsManager.h @@ -45,7 +45,7 @@ class AnimationsManager : public Actor { SecretInputMedia get_secret_input_media(FileId animation_file_id, tl_object_ptr input_file, - const string &caption, BufferSlice thumbnail) const; + const string &caption, BufferSlice thumbnail, int32 layer) const; FileId get_animation_thumbnail_file_id(FileId file_id) const; diff --git a/td/telegram/AudiosManager.cpp b/td/telegram/AudiosManager.cpp index 836eae8c..a29d1107 100644 --- a/td/telegram/AudiosManager.cpp +++ b/td/telegram/AudiosManager.cpp @@ -201,7 +201,7 @@ SecretInputMedia AudiosManager::get_secret_input_media(FileId audio_file_id, attributes.push_back(make_tl_object(audio->file_name)); } attributes.push_back(make_tl_object( - secret_api::documentAttributeAudio::Flags::TITLE_MASK | secret_api::documentAttributeAudio::Flags::PERFORMER_MASK, + secret_api::documentAttributeAudio::TITLE_MASK | secret_api::documentAttributeAudio::PERFORMER_MASK, false /*ignored*/, audio->duration, audio->title, audio->performer, BufferSlice())); return SecretInputMedia{ diff --git a/td/telegram/CallActor.cpp b/td/telegram/CallActor.cpp index ae4cb8c4..3db60cf7 100644 --- a/td/telegram/CallActor.cpp +++ b/td/telegram/CallActor.cpp @@ -43,10 +43,10 @@ CallProtocol CallProtocol::from_telegram_api(const telegram_api::phoneCallProtoc tl_object_ptr CallProtocol::as_telegram_api() const { int32 flags = 0; if (udp_p2p) { - flags |= telegram_api::phoneCallProtocol::Flags::UDP_P2P_MASK; + flags |= telegram_api::phoneCallProtocol::UDP_P2P_MASK; } if (udp_reflector) { - flags |= telegram_api::phoneCallProtocol::Flags::UDP_REFLECTOR_MASK; + flags |= telegram_api::phoneCallProtocol::UDP_REFLECTOR_MASK; } return make_tl_object(flags, udp_p2p, udp_reflector, min_layer, max_layer); } diff --git a/td/telegram/DocumentsManager.cpp b/td/telegram/DocumentsManager.cpp index daa14d88..5bd323cb 100644 --- a/td/telegram/DocumentsManager.cpp +++ b/td/telegram/DocumentsManager.cpp @@ -139,7 +139,7 @@ std::pair DocumentsManager::on_get_docum default_document_type == DocumentType::VoiceNote) { bool is_voice_note = default_document_type == DocumentType::VoiceNote; if (audio != nullptr) { - is_voice_note = (audio->flags_ & telegram_api::documentAttributeAudio::Flags::VOICE_MASK) != 0; + is_voice_note = (audio->flags_ & telegram_api::documentAttributeAudio::VOICE_MASK) != 0; } if (is_voice_note) { document_type = DocumentType::VoiceNote; diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 48529514..c3a53154 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -1710,7 +1710,7 @@ SecretInputMedia get_secret_input_media(const MessageContent *content, Td *td, case MessageContentType::Animation: { auto m = static_cast(content); return td->animations_manager_->get_secret_input_media(m->file_id, std::move(input_file), m->caption.text, - std::move(thumbnail)); + std::move(thumbnail), layer); } case MessageContentType::Audio: { auto m = static_cast(content); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index e962cd87..4bbe6a4c 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -14684,7 +14684,7 @@ Status MessagesManager::can_send_message_content(DialogId dialog_id, const Messa if (!can_send_media) { return Status::Error(400, "Not enough rights to send video notes to the chat"); } - if (secret_chat_layer < SecretChatActor::VOICE_NOTES_LAYER) { + if (secret_chat_layer < SecretChatActor::VIDEO_NOTES_LAYER) { return Status::Error(400, PSLICE() << "Video notes can't be sent to secret chat with layer " << secret_chat_layer); } diff --git a/td/telegram/SecretChatActor.cpp b/td/telegram/SecretChatActor.cpp index c221c9ba..627c64a8 100644 --- a/td/telegram/SecretChatActor.cpp +++ b/td/telegram/SecretChatActor.cpp @@ -237,7 +237,7 @@ static int32 get_min_layer(const secret_api::decryptedMessageActionTyping &messa switch (message.action_->get_id()) { case secret_api::sendMessageRecordRoundAction::ID: case secret_api::sendMessageUploadRoundAction::ID: - return SecretChatActor::VOICE_NOTES_LAYER; + return SecretChatActor::VIDEO_NOTES_LAYER; } return 0; } @@ -252,7 +252,7 @@ static int32 get_min_layer(const secret_api::decryptedMessageService &message) { static int32 get_min_layer(const secret_api::DocumentAttribute &attribute) { switch (attribute.get_id()) { case secret_api::documentAttributeVideo66::ID: - return SecretChatActor::VOICE_NOTES_LAYER; + return SecretChatActor::VIDEO_NOTES_LAYER; default: return 0; } diff --git a/td/telegram/SecretChatActor.h b/td/telegram/SecretChatActor.h index 4dc6684e..683f9fa5 100644 --- a/td/telegram/SecretChatActor.h +++ b/td/telegram/SecretChatActor.h @@ -41,13 +41,14 @@ #include namespace td { + class BinlogInterface; class NetQueryCreator; class SecretChatActor : public NetQueryCallback { public: // do not change DEFAULT_LAYER, unless all it's usages are fixed - enum : int32 { DEFAULT_LAYER = 46, VOICE_NOTES_LAYER = 66, MTPROTO_2_LAYER = 73, MY_LAYER = MTPROTO_2_LAYER }; + enum : int32 { DEFAULT_LAYER = 46, VIDEO_NOTES_LAYER = 66, MTPROTO_2_LAYER = 73, MY_LAYER = MTPROTO_2_LAYER }; class Context { public: @@ -684,4 +685,5 @@ class SecretChatActor : public NetQueryCallback { << tag("his_in_seq_no", state.his_in_seq_no) << "]"; } }; + } // namespace td diff --git a/td/telegram/VideoNotesManager.cpp b/td/telegram/VideoNotesManager.cpp index fff544a2..e5cb145f 100644 --- a/td/telegram/VideoNotesManager.cpp +++ b/td/telegram/VideoNotesManager.cpp @@ -175,10 +175,10 @@ SecretInputMedia VideoNotesManager::get_secret_input_media(FileId video_note_fil if (video_note->thumbnail.file_id.is_valid() && thumbnail.empty()) { return SecretInputMedia{}; } - CHECK(layer >= SecretChatActor::VOICE_NOTES_LAYER); + CHECK(layer >= SecretChatActor::VIDEO_NOTES_LAYER); vector> attributes; attributes.push_back(make_tl_object( - secret_api::documentAttributeVideo66::Flags::ROUND_MESSAGE_MASK, true, video_note->duration, + secret_api::documentAttributeVideo66::ROUND_MESSAGE_MASK, true, video_note->duration, video_note->dimensions.width, video_note->dimensions.height)); return SecretInputMedia{ std::move(input_file), diff --git a/td/telegram/VoiceNotesManager.cpp b/td/telegram/VoiceNotesManager.cpp index bb72bbf2..98bd24ff 100644 --- a/td/telegram/VoiceNotesManager.cpp +++ b/td/telegram/VoiceNotesManager.cpp @@ -154,7 +154,7 @@ SecretInputMedia VoiceNotesManager::get_secret_input_media(FileId voice_file_id, } vector> attributes; attributes.push_back(make_tl_object( - secret_api::documentAttributeAudio::Flags::VOICE_MASK | secret_api::documentAttributeAudio::Flags::WAVEFORM_MASK, + secret_api::documentAttributeAudio::VOICE_MASK | secret_api::documentAttributeAudio::WAVEFORM_MASK, false /*ignored*/, voice_note->duration, "", "", BufferSlice(voice_note->waveform))); return SecretInputMedia{std::move(input_file), make_tl_object(