Fix sending of secret_api::documentAttributeVideo.
GitOrigin-RevId: b4247fe902cbf64dc12e67cc1f41f140b60db65a
This commit is contained in:
parent
7e3ab0348a
commit
d580eb7818
|
@ -13,6 +13,7 @@
|
||||||
#include "td/telegram/Global.h"
|
#include "td/telegram/Global.h"
|
||||||
#include "td/telegram/logevent/LogEvent.h"
|
#include "td/telegram/logevent/LogEvent.h"
|
||||||
#include "td/telegram/misc.h"
|
#include "td/telegram/misc.h"
|
||||||
|
#include "td/telegram/SecretChatActor.h"
|
||||||
#include "td/telegram/Td.h"
|
#include "td/telegram/Td.h"
|
||||||
|
|
||||||
#include "td/telegram/secret_api.h"
|
#include "td/telegram/secret_api.h"
|
||||||
|
@ -305,7 +306,8 @@ tl_object_ptr<telegram_api::InputMedia> AnimationsManager::get_input_media(
|
||||||
}
|
}
|
||||||
SecretInputMedia AnimationsManager::get_secret_input_media(FileId animation_file_id,
|
SecretInputMedia AnimationsManager::get_secret_input_media(FileId animation_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,
|
||||||
|
int32 layer) const {
|
||||||
auto *animation = get_animation(animation_file_id);
|
auto *animation = get_animation(animation_file_id);
|
||||||
CHECK(animation != nullptr);
|
CHECK(animation != nullptr);
|
||||||
auto file_view = td_->file_manager_->get_file_view(animation_file_id);
|
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<secret_api::documentAttributeFilename>(animation->file_name));
|
attributes.push_back(make_tl_object<secret_api::documentAttributeFilename>(animation->file_name));
|
||||||
}
|
}
|
||||||
if (animation->duration != 0 && animation->mime_type == "video/mp4") {
|
if (animation->duration != 0 && animation->mime_type == "video/mp4") {
|
||||||
attributes.push_back(make_tl_object<secret_api::documentAttributeVideo>(
|
if (layer >= SecretChatActor::VIDEO_NOTES_LAYER) {
|
||||||
animation->duration, animation->dimensions.width, animation->dimensions.height));
|
attributes.push_back(make_tl_object<secret_api::documentAttributeVideo66>(
|
||||||
|
0, false, animation->duration, animation->dimensions.width, animation->dimensions.height));
|
||||||
|
} else {
|
||||||
|
attributes.push_back(make_tl_object<secret_api::documentAttributeVideo>(
|
||||||
|
animation->duration, animation->dimensions.width, animation->dimensions.height));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (animation->dimensions.width != 0 && animation->dimensions.height != 0) {
|
if (animation->dimensions.width != 0 && animation->dimensions.height != 0) {
|
||||||
attributes.push_back(make_tl_object<secret_api::documentAttributeImageSize>(animation->dimensions.width,
|
attributes.push_back(make_tl_object<secret_api::documentAttributeImageSize>(animation->dimensions.width,
|
||||||
|
|
|
@ -45,7 +45,7 @@ class AnimationsManager : public Actor {
|
||||||
|
|
||||||
SecretInputMedia get_secret_input_media(FileId animation_file_id,
|
SecretInputMedia get_secret_input_media(FileId animation_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, int32 layer) const;
|
||||||
|
|
||||||
FileId get_animation_thumbnail_file_id(FileId file_id) const;
|
FileId get_animation_thumbnail_file_id(FileId file_id) const;
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,7 @@ SecretInputMedia AudiosManager::get_secret_input_media(FileId audio_file_id,
|
||||||
attributes.push_back(make_tl_object<secret_api::documentAttributeFilename>(audio->file_name));
|
attributes.push_back(make_tl_object<secret_api::documentAttributeFilename>(audio->file_name));
|
||||||
}
|
}
|
||||||
attributes.push_back(make_tl_object<secret_api::documentAttributeAudio>(
|
attributes.push_back(make_tl_object<secret_api::documentAttributeAudio>(
|
||||||
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()));
|
false /*ignored*/, audio->duration, audio->title, audio->performer, BufferSlice()));
|
||||||
|
|
||||||
return SecretInputMedia{
|
return SecretInputMedia{
|
||||||
|
|
|
@ -43,10 +43,10 @@ CallProtocol CallProtocol::from_telegram_api(const telegram_api::phoneCallProtoc
|
||||||
tl_object_ptr<telegram_api::phoneCallProtocol> CallProtocol::as_telegram_api() const {
|
tl_object_ptr<telegram_api::phoneCallProtocol> CallProtocol::as_telegram_api() const {
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
if (udp_p2p) {
|
if (udp_p2p) {
|
||||||
flags |= telegram_api::phoneCallProtocol::Flags::UDP_P2P_MASK;
|
flags |= telegram_api::phoneCallProtocol::UDP_P2P_MASK;
|
||||||
}
|
}
|
||||||
if (udp_reflector) {
|
if (udp_reflector) {
|
||||||
flags |= telegram_api::phoneCallProtocol::Flags::UDP_REFLECTOR_MASK;
|
flags |= telegram_api::phoneCallProtocol::UDP_REFLECTOR_MASK;
|
||||||
}
|
}
|
||||||
return make_tl_object<telegram_api::phoneCallProtocol>(flags, udp_p2p, udp_reflector, min_layer, max_layer);
|
return make_tl_object<telegram_api::phoneCallProtocol>(flags, udp_p2p, udp_reflector, min_layer, max_layer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ std::pair<DocumentsManager::DocumentType, FileId> DocumentsManager::on_get_docum
|
||||||
default_document_type == DocumentType::VoiceNote) {
|
default_document_type == DocumentType::VoiceNote) {
|
||||||
bool is_voice_note = default_document_type == DocumentType::VoiceNote;
|
bool is_voice_note = default_document_type == DocumentType::VoiceNote;
|
||||||
if (audio != nullptr) {
|
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) {
|
if (is_voice_note) {
|
||||||
document_type = DocumentType::VoiceNote;
|
document_type = DocumentType::VoiceNote;
|
||||||
|
|
|
@ -1710,7 +1710,7 @@ SecretInputMedia get_secret_input_media(const MessageContent *content, Td *td,
|
||||||
case MessageContentType::Animation: {
|
case MessageContentType::Animation: {
|
||||||
auto m = static_cast<const MessageAnimation *>(content);
|
auto m = static_cast<const MessageAnimation *>(content);
|
||||||
return td->animations_manager_->get_secret_input_media(m->file_id, std::move(input_file), m->caption.text,
|
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: {
|
case MessageContentType::Audio: {
|
||||||
auto m = static_cast<const MessageAudio *>(content);
|
auto m = static_cast<const MessageAudio *>(content);
|
||||||
|
|
|
@ -14684,7 +14684,7 @@ Status MessagesManager::can_send_message_content(DialogId dialog_id, const Messa
|
||||||
if (!can_send_media) {
|
if (!can_send_media) {
|
||||||
return Status::Error(400, "Not enough rights to send video notes to the chat");
|
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()
|
return Status::Error(400, PSLICE()
|
||||||
<< "Video notes can't be sent to secret chat with layer " << secret_chat_layer);
|
<< "Video notes can't be sent to secret chat with layer " << secret_chat_layer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ static int32 get_min_layer(const secret_api::decryptedMessageActionTyping &messa
|
||||||
switch (message.action_->get_id()) {
|
switch (message.action_->get_id()) {
|
||||||
case secret_api::sendMessageRecordRoundAction::ID:
|
case secret_api::sendMessageRecordRoundAction::ID:
|
||||||
case secret_api::sendMessageUploadRoundAction::ID:
|
case secret_api::sendMessageUploadRoundAction::ID:
|
||||||
return SecretChatActor::VOICE_NOTES_LAYER;
|
return SecretChatActor::VIDEO_NOTES_LAYER;
|
||||||
}
|
}
|
||||||
return 0;
|
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) {
|
static int32 get_min_layer(const secret_api::DocumentAttribute &attribute) {
|
||||||
switch (attribute.get_id()) {
|
switch (attribute.get_id()) {
|
||||||
case secret_api::documentAttributeVideo66::ID:
|
case secret_api::documentAttributeVideo66::ID:
|
||||||
return SecretChatActor::VOICE_NOTES_LAYER;
|
return SecretChatActor::VIDEO_NOTES_LAYER;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,13 +41,14 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
class BinlogInterface;
|
class BinlogInterface;
|
||||||
class NetQueryCreator;
|
class NetQueryCreator;
|
||||||
|
|
||||||
class SecretChatActor : public NetQueryCallback {
|
class SecretChatActor : public NetQueryCallback {
|
||||||
public:
|
public:
|
||||||
// do not change DEFAULT_LAYER, unless all it's usages are fixed
|
// 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 {
|
class Context {
|
||||||
public:
|
public:
|
||||||
|
@ -684,4 +685,5 @@ class SecretChatActor : public NetQueryCallback {
|
||||||
<< tag("his_in_seq_no", state.his_in_seq_no) << "]";
|
<< tag("his_in_seq_no", state.his_in_seq_no) << "]";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|
|
@ -175,10 +175,10 @@ SecretInputMedia VideoNotesManager::get_secret_input_media(FileId video_note_fil
|
||||||
if (video_note->thumbnail.file_id.is_valid() && thumbnail.empty()) {
|
if (video_note->thumbnail.file_id.is_valid() && thumbnail.empty()) {
|
||||||
return SecretInputMedia{};
|
return SecretInputMedia{};
|
||||||
}
|
}
|
||||||
CHECK(layer >= SecretChatActor::VOICE_NOTES_LAYER);
|
CHECK(layer >= SecretChatActor::VIDEO_NOTES_LAYER);
|
||||||
vector<tl_object_ptr<secret_api::DocumentAttribute>> attributes;
|
vector<tl_object_ptr<secret_api::DocumentAttribute>> attributes;
|
||||||
attributes.push_back(make_tl_object<secret_api::documentAttributeVideo66>(
|
attributes.push_back(make_tl_object<secret_api::documentAttributeVideo66>(
|
||||||
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));
|
video_note->dimensions.width, video_note->dimensions.height));
|
||||||
return SecretInputMedia{
|
return SecretInputMedia{
|
||||||
std::move(input_file),
|
std::move(input_file),
|
||||||
|
|
|
@ -154,7 +154,7 @@ SecretInputMedia VoiceNotesManager::get_secret_input_media(FileId voice_file_id,
|
||||||
}
|
}
|
||||||
vector<tl_object_ptr<secret_api::DocumentAttribute>> attributes;
|
vector<tl_object_ptr<secret_api::DocumentAttribute>> attributes;
|
||||||
attributes.push_back(make_tl_object<secret_api::documentAttributeAudio>(
|
attributes.push_back(make_tl_object<secret_api::documentAttributeAudio>(
|
||||||
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)));
|
false /*ignored*/, voice_note->duration, "", "", BufferSlice(voice_note->waveform)));
|
||||||
return SecretInputMedia{std::move(input_file),
|
return SecretInputMedia{std::move(input_file),
|
||||||
make_tl_object<secret_api::decryptedMessageMediaDocument>(
|
make_tl_object<secret_api::decryptedMessageMediaDocument>(
|
||||||
|
|
Reference in New Issue
Block a user