2022-05-11 00:53:18 +02:00
|
|
|
//
|
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#include "td/telegram/SecretInputMedia.h"
|
|
|
|
|
|
|
|
#include "td/telegram/files/FileManager.h"
|
2022-05-11 06:46:06 +02:00
|
|
|
#include "td/telegram/SecretChatLayer.h"
|
2022-05-11 00:53:18 +02:00
|
|
|
|
2022-06-02 15:19:16 +02:00
|
|
|
#include "td/utils/misc.h"
|
|
|
|
|
2022-05-11 00:53:18 +02:00
|
|
|
namespace td {
|
|
|
|
|
|
|
|
SecretInputMedia::SecretInputMedia(tl_object_ptr<telegram_api::InputEncryptedFile> input_file, BufferSlice &&thumbnail,
|
|
|
|
Dimensions thumbnail_dimensions, const string &mime_type, const FileView &file_view,
|
|
|
|
vector<tl_object_ptr<secret_api::DocumentAttribute>> &&attributes,
|
2022-05-11 06:46:06 +02:00
|
|
|
const string &caption, int32 layer)
|
2022-05-11 00:53:18 +02:00
|
|
|
: input_file_(std::move(input_file)) {
|
|
|
|
auto &encryption_key = file_view.encryption_key();
|
2022-05-11 06:46:06 +02:00
|
|
|
auto size = file_view.size();
|
|
|
|
if (layer >= static_cast<int32>(SecretChatLayer::SupportBigFiles)) {
|
|
|
|
decrypted_media_ = secret_api::make_object<secret_api::decryptedMessageMediaDocument>(
|
|
|
|
std::move(thumbnail), thumbnail_dimensions.width, thumbnail_dimensions.height, mime_type, size,
|
|
|
|
BufferSlice(encryption_key.key_slice()), BufferSlice(encryption_key.iv_slice()), std::move(attributes),
|
|
|
|
caption);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (size <= (2000 << 20)) {
|
|
|
|
decrypted_media_ = secret_api::make_object<secret_api::decryptedMessageMediaDocument46>(
|
|
|
|
std::move(thumbnail), thumbnail_dimensions.width, thumbnail_dimensions.height, mime_type,
|
|
|
|
narrow_cast<int32>(size), BufferSlice(encryption_key.key_slice()), BufferSlice(encryption_key.iv_slice()),
|
|
|
|
std::move(attributes), caption);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
input_file_ = nullptr;
|
2022-05-11 00:53:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|