Improve names of get_input_media functions from MessageContent.
This commit is contained in:
parent
d93d5a535f
commit
c24222546e
@ -848,7 +848,8 @@ void BusinessConnectionManager::do_send_message(unique_ptr<PendingMessage> &&mes
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto input_media = get_input_media(content, td_, message->ttl_, message->send_emoji_, td_->auth_manager_->is_bot());
|
auto input_media =
|
||||||
|
get_message_content_input_media(content, td_, message->ttl_, message->send_emoji_, td_->auth_manager_->is_bot());
|
||||||
if (input_media != nullptr) {
|
if (input_media != nullptr) {
|
||||||
td_->create_handler<SendBusinessMediaQuery>(std::move(promise))->send(std::move(message), std::move(input_media));
|
td_->create_handler<SendBusinessMediaQuery>(std::move(promise))->send(std::move(message), std::move(input_media));
|
||||||
return;
|
return;
|
||||||
@ -1005,8 +1006,9 @@ void BusinessConnectionManager::do_upload_media(BeingUploadedMedia &&being_uploa
|
|||||||
<< ", have_input_file = " << have_input_file << ", have_input_thumbnail = " << have_input_thumbnail;
|
<< ", have_input_file = " << have_input_file << ", have_input_thumbnail = " << have_input_thumbnail;
|
||||||
|
|
||||||
const auto *message = being_uploaded_media.message_.get();
|
const auto *message = being_uploaded_media.message_.get();
|
||||||
auto input_media = get_input_media(message->content_.get(), td_, std::move(input_file), std::move(input_thumbnail),
|
auto input_media =
|
||||||
file_id, thumbnail_file_id, message->ttl_, message->send_emoji_, true);
|
get_message_content_input_media(message->content_.get(), td_, std::move(input_file), std::move(input_thumbnail),
|
||||||
|
file_id, thumbnail_file_id, message->ttl_, message->send_emoji_, true);
|
||||||
CHECK(input_media != nullptr);
|
CHECK(input_media != nullptr);
|
||||||
auto input_media_id = input_media->get_id();
|
auto input_media_id = input_media->get_id();
|
||||||
if (input_media_id == telegram_api::inputMediaDocument::ID || input_media_id == telegram_api::inputMediaPhoto::ID) {
|
if (input_media_id == telegram_api::inputMediaDocument::ID || input_media_id == telegram_api::inputMediaPhoto::ID) {
|
||||||
@ -1073,7 +1075,8 @@ void BusinessConnectionManager::complete_upload_media(unique_ptr<PendingMessage>
|
|||||||
update_message_content_file_id_remote(old_content.get(), get_message_content_any_file_id(new_content.get()));
|
update_message_content_file_id_remote(old_content.get(), get_message_content_any_file_id(new_content.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto input_media = get_input_media(message->content_.get(), td_, message->ttl_, message->send_emoji_, true);
|
auto input_media =
|
||||||
|
get_message_content_input_media(message->content_.get(), td_, message->ttl_, message->send_emoji_, true);
|
||||||
if (input_media == nullptr) {
|
if (input_media == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Failed to upload file"));
|
return promise.set_error(Status::Error(400, "Failed to upload file"));
|
||||||
}
|
}
|
||||||
@ -1109,8 +1112,8 @@ void BusinessConnectionManager::send_message_album(
|
|||||||
auto message =
|
auto message =
|
||||||
create_business_message_to_send(business_connection_id, dialog_id, input_reply_to.clone(), disable_notification,
|
create_business_message_to_send(business_connection_id, dialog_id, input_reply_to.clone(), disable_notification,
|
||||||
protect_content, effect_id, nullptr, std::move(message_content));
|
protect_content, effect_id, nullptr, std::move(message_content));
|
||||||
auto input_media = get_input_media(message->content_.get(), td_, message->ttl_, message->send_emoji_,
|
auto input_media = get_message_content_input_media(message->content_.get(), td_, message->ttl_,
|
||||||
td_->auth_manager_->is_bot());
|
message->send_emoji_, td_->auth_manager_->is_bot());
|
||||||
if (input_media != nullptr) {
|
if (input_media != nullptr) {
|
||||||
auto file_id = get_message_file_id(message);
|
auto file_id = get_message_file_id(message);
|
||||||
CHECK(file_id.is_valid());
|
CHECK(file_id.is_valid());
|
||||||
@ -1303,7 +1306,8 @@ void BusinessConnectionManager::edit_business_message_media(
|
|||||||
TRY_RESULT_PROMISE(promise, new_reply_markup,
|
TRY_RESULT_PROMISE(promise, new_reply_markup,
|
||||||
get_reply_markup(std::move(reply_markup), td_->auth_manager_->is_bot(), true, false, true));
|
get_reply_markup(std::move(reply_markup), td_->auth_manager_->is_bot(), true, false, true));
|
||||||
|
|
||||||
auto input_media = get_input_media(content.content.get(), td_, MessageSelfDestructType(), string(), true);
|
auto input_media =
|
||||||
|
get_message_content_input_media(content.content.get(), td_, MessageSelfDestructType(), string(), true);
|
||||||
if (input_media != nullptr) {
|
if (input_media != nullptr) {
|
||||||
auto file_id = get_message_content_any_file_id(content.content.get());
|
auto file_id = get_message_content_any_file_id(content.content.get());
|
||||||
CHECK(file_id.is_valid());
|
CHECK(file_id.is_valid());
|
||||||
|
@ -314,7 +314,8 @@ void InlineMessageManager::edit_inline_message_media(
|
|||||||
get_reply_markup(std::move(reply_markup), td_->auth_manager_->is_bot(), true, false, true));
|
get_reply_markup(std::move(reply_markup), td_->auth_manager_->is_bot(), true, false, true));
|
||||||
TRY_RESULT_PROMISE(promise, input_bot_inline_message_id, get_input_bot_inline_message_id(inline_message_id));
|
TRY_RESULT_PROMISE(promise, input_bot_inline_message_id, get_input_bot_inline_message_id(inline_message_id));
|
||||||
|
|
||||||
auto input_media = get_input_media(content.content.get(), td_, MessageSelfDestructType(), string(), true);
|
auto input_media =
|
||||||
|
get_message_content_input_media(content.content.get(), td_, MessageSelfDestructType(), string(), true);
|
||||||
if (input_media == nullptr) {
|
if (input_media == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Invalid message content specified"));
|
return promise.set_error(Status::Error(400, "Invalid message content specified"));
|
||||||
}
|
}
|
||||||
|
@ -3167,7 +3167,7 @@ Status check_message_group_message_contents(const vector<InputMessageContent> &m
|
|||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool can_have_input_media(const Td *td, const MessageContent *content, bool is_server) {
|
bool can_message_content_have_input_media(const Td *td, const MessageContent *content, bool is_server) {
|
||||||
switch (content->get_type()) {
|
switch (content->get_type()) {
|
||||||
case MessageContentType::Game:
|
case MessageContentType::Game:
|
||||||
return is_server || static_cast<const MessageGame *>(content)->game.has_input_media();
|
return is_server || static_cast<const MessageGame *>(content)->game.has_input_media();
|
||||||
@ -3260,9 +3260,9 @@ bool can_have_input_media(const Td *td, const MessageContent *content, bool is_s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SecretInputMedia get_secret_input_media(const MessageContent *content, Td *td,
|
SecretInputMedia get_message_content_secret_input_media(
|
||||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
const MessageContent *content, Td *td, telegram_api::object_ptr<telegram_api::InputEncryptedFile> input_file,
|
||||||
BufferSlice thumbnail, int32 layer) {
|
BufferSlice thumbnail, int32 layer) {
|
||||||
switch (content->get_type()) {
|
switch (content->get_type()) {
|
||||||
case MessageContentType::Animation: {
|
case MessageContentType::Animation: {
|
||||||
const auto *m = static_cast<const MessageAnimation *>(content);
|
const auto *m = static_cast<const MessageAnimation *>(content);
|
||||||
@ -3388,10 +3388,11 @@ SecretInputMedia get_secret_input_media(const MessageContent *content, Td *td,
|
|||||||
return SecretInputMedia{};
|
return SecretInputMedia{};
|
||||||
}
|
}
|
||||||
|
|
||||||
static tl_object_ptr<telegram_api::InputMedia> get_input_media_impl(
|
static telegram_api::object_ptr<telegram_api::InputMedia> get_message_content_input_media_impl(
|
||||||
const MessageContent *content, Td *td, tl_object_ptr<telegram_api::InputFile> input_file,
|
const MessageContent *content, Td *td, telegram_api::object_ptr<telegram_api::InputFile> input_file,
|
||||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail, MessageSelfDestructType ttl, const string &emoji) {
|
telegram_api::object_ptr<telegram_api::InputFile> input_thumbnail, MessageSelfDestructType ttl,
|
||||||
if (!can_have_input_media(td, content, false)) {
|
const string &emoji) {
|
||||||
|
if (!can_message_content_have_input_media(td, content, false)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
switch (content->get_type()) {
|
switch (content->get_type()) {
|
||||||
@ -3544,14 +3545,14 @@ static tl_object_ptr<telegram_api::InputMedia> get_input_media_impl(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(const MessageContent *content, Td *td,
|
telegram_api::object_ptr<telegram_api::InputMedia> get_message_content_input_media(
|
||||||
tl_object_ptr<telegram_api::InputFile> input_file,
|
const MessageContent *content, Td *td, telegram_api::object_ptr<telegram_api::InputFile> input_file,
|
||||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail,
|
telegram_api::object_ptr<telegram_api::InputFile> input_thumbnail, FileId file_id, FileId thumbnail_file_id,
|
||||||
FileId file_id, FileId thumbnail_file_id,
|
MessageSelfDestructType ttl, const string &emoji, bool force) {
|
||||||
MessageSelfDestructType ttl, const string &emoji, bool force) {
|
|
||||||
bool had_input_file = input_file != nullptr;
|
bool had_input_file = input_file != nullptr;
|
||||||
bool had_input_thumbnail = input_thumbnail != nullptr;
|
bool had_input_thumbnail = input_thumbnail != nullptr;
|
||||||
auto input_media = get_input_media_impl(content, td, std::move(input_file), std::move(input_thumbnail), ttl, emoji);
|
auto input_media =
|
||||||
|
get_message_content_input_media_impl(content, td, std::move(input_file), std::move(input_thumbnail), ttl, emoji);
|
||||||
auto was_uploaded = FileManager::extract_was_uploaded(input_media);
|
auto was_uploaded = FileManager::extract_was_uploaded(input_media);
|
||||||
if (had_input_file) {
|
if (had_input_file) {
|
||||||
if (!was_uploaded) {
|
if (!was_uploaded) {
|
||||||
@ -3582,9 +3583,10 @@ tl_object_ptr<telegram_api::InputMedia> get_input_media(const MessageContent *co
|
|||||||
return input_media;
|
return input_media;
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(const MessageContent *content, Td *td,
|
telegram_api::object_ptr<telegram_api::InputMedia> get_message_content_input_media(const MessageContent *content,
|
||||||
MessageSelfDestructType ttl, const string &emoji, bool force) {
|
Td *td, MessageSelfDestructType ttl,
|
||||||
auto input_media = get_input_media_impl(content, td, nullptr, nullptr, ttl, emoji);
|
const string &emoji, bool force) {
|
||||||
|
auto input_media = get_message_content_input_media_impl(content, td, nullptr, nullptr, ttl, emoji);
|
||||||
auto file_references = FileManager::extract_file_references(input_media);
|
auto file_references = FileManager::extract_file_references(input_media);
|
||||||
for (size_t i = 0; i < file_references.size(); i++) {
|
for (size_t i = 0; i < file_references.size(); i++) {
|
||||||
if (file_references[i] == FileReferenceView::invalid_file_reference()) {
|
if (file_references[i] == FileReferenceView::invalid_file_reference()) {
|
||||||
@ -3601,17 +3603,17 @@ tl_object_ptr<telegram_api::InputMedia> get_input_media(const MessageContent *co
|
|||||||
return input_media;
|
return input_media;
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::InputMedia> get_fake_input_media(Td *td, tl_object_ptr<telegram_api::InputFile> input_file,
|
telegram_api::object_ptr<telegram_api::InputMedia> get_message_content_fake_input_media(
|
||||||
FileId file_id) {
|
Td *td, telegram_api::object_ptr<telegram_api::InputFile> input_file, FileId file_id) {
|
||||||
FileView file_view = td->file_manager_->get_file_view(file_id);
|
FileView file_view = td->file_manager_->get_file_view(file_id);
|
||||||
auto file_type = file_view.get_type();
|
auto file_type = file_view.get_type();
|
||||||
if (is_document_file_type(file_type)) {
|
if (is_document_file_type(file_type)) {
|
||||||
vector<tl_object_ptr<telegram_api::DocumentAttribute>> attributes;
|
vector<telegram_api::object_ptr<telegram_api::DocumentAttribute>> attributes;
|
||||||
auto file_path = file_view.suggested_path();
|
auto file_path = file_view.suggested_path();
|
||||||
const PathView path_view(file_path);
|
const PathView path_view(file_path);
|
||||||
Slice file_name = path_view.file_name();
|
Slice file_name = path_view.file_name();
|
||||||
if (!file_name.empty()) {
|
if (!file_name.empty()) {
|
||||||
attributes.push_back(make_tl_object<telegram_api::documentAttributeFilename>(file_name.str()));
|
attributes.push_back(telegram_api::make_object<telegram_api::documentAttributeFilename>(file_name.str()));
|
||||||
}
|
}
|
||||||
string mime_type = MimeType::from_extension(path_view.extension());
|
string mime_type = MimeType::from_extension(path_view.extension());
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
@ -3621,19 +3623,20 @@ tl_object_ptr<telegram_api::InputMedia> get_fake_input_media(Td *td, tl_object_p
|
|||||||
if (file_type == FileType::DocumentAsFile) {
|
if (file_type == FileType::DocumentAsFile) {
|
||||||
flags |= telegram_api::inputMediaUploadedDocument::FORCE_FILE_MASK;
|
flags |= telegram_api::inputMediaUploadedDocument::FORCE_FILE_MASK;
|
||||||
}
|
}
|
||||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
return telegram_api::make_object<telegram_api::inputMediaUploadedDocument>(
|
||||||
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, std::move(input_file), nullptr, mime_type,
|
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, std::move(input_file), nullptr, mime_type,
|
||||||
std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
std::move(attributes), vector<telegram_api::object_ptr<telegram_api::InputDocument>>(), 0);
|
||||||
} else {
|
} else {
|
||||||
CHECK(file_type == FileType::Photo || file_type == FileType::PhotoStory);
|
CHECK(file_type == FileType::Photo || file_type == FileType::PhotoStory);
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
return make_tl_object<telegram_api::inputMediaUploadedPhoto>(
|
return telegram_api::make_object<telegram_api::inputMediaUploadedPhoto>(
|
||||||
flags, false /*ignored*/, std::move(input_file), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
flags, false /*ignored*/, std::move(input_file),
|
||||||
|
vector<telegram_api::object_ptr<telegram_api::InputDocument>>(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::InputMedia> get_message_content_input_media_web_page(const Td *td,
|
telegram_api::object_ptr<telegram_api::InputMedia> get_message_content_input_media_web_page(
|
||||||
const MessageContent *content) {
|
const Td *td, const MessageContent *content) {
|
||||||
CHECK(content != nullptr);
|
CHECK(content != nullptr);
|
||||||
if (content->get_type() != MessageContentType::Text) {
|
if (content->get_type() != MessageContentType::Text) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -6507,7 +6510,7 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
|
|||||||
CHECK(type == MessageContentDupType::Copy || type == MessageContentDupType::ServerCopy);
|
CHECK(type == MessageContentDupType::Copy || type == MessageContentDupType::ServerCopy);
|
||||||
}
|
}
|
||||||
if (type != MessageContentDupType::Forward && type != MessageContentDupType::SendViaBot &&
|
if (type != MessageContentDupType::Forward && type != MessageContentDupType::SendViaBot &&
|
||||||
!can_have_input_media(td, content, type == MessageContentDupType::ServerCopy)) {
|
!can_message_content_have_input_media(td, content, type == MessageContentDupType::ServerCopy)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,26 +121,26 @@ Result<InputMessageContent> get_input_message_content(
|
|||||||
|
|
||||||
Status check_message_group_message_contents(const vector<InputMessageContent> &message_contents);
|
Status check_message_group_message_contents(const vector<InputMessageContent> &message_contents);
|
||||||
|
|
||||||
bool can_have_input_media(const Td *td, const MessageContent *content, bool is_server);
|
bool can_message_content_have_input_media(const Td *td, const MessageContent *content, bool is_server);
|
||||||
|
|
||||||
SecretInputMedia get_secret_input_media(const MessageContent *content, Td *td,
|
SecretInputMedia get_message_content_secret_input_media(
|
||||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
const MessageContent *content, Td *td, telegram_api::object_ptr<telegram_api::InputEncryptedFile> input_file,
|
||||||
BufferSlice thumbnail, int32 layer);
|
BufferSlice thumbnail, int32 layer);
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(const MessageContent *content, Td *td,
|
telegram_api::object_ptr<telegram_api::InputMedia> get_message_content_input_media(
|
||||||
tl_object_ptr<telegram_api::InputFile> input_file,
|
const MessageContent *content, Td *td, telegram_api::object_ptr<telegram_api::InputFile> input_file,
|
||||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail,
|
telegram_api::object_ptr<telegram_api::InputFile> input_thumbnail, FileId file_id, FileId thumbnail_file_id,
|
||||||
FileId file_id, FileId thumbnail_file_id,
|
MessageSelfDestructType ttl, const string &emoji, bool force);
|
||||||
MessageSelfDestructType ttl, const string &emoji, bool force);
|
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(const MessageContent *content, Td *td,
|
telegram_api::object_ptr<telegram_api::InputMedia> get_message_content_input_media(const MessageContent *content,
|
||||||
MessageSelfDestructType ttl, const string &emoji, bool force);
|
Td *td, MessageSelfDestructType ttl,
|
||||||
|
const string &emoji, bool force);
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::InputMedia> get_fake_input_media(Td *td, tl_object_ptr<telegram_api::InputFile> input_file,
|
telegram_api::object_ptr<telegram_api::InputMedia> get_message_content_fake_input_media(
|
||||||
FileId file_id);
|
Td *td, telegram_api::object_ptr<telegram_api::InputFile> input_file, FileId file_id);
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::InputMedia> get_message_content_input_media_web_page(const Td *td,
|
telegram_api::object_ptr<telegram_api::InputMedia> get_message_content_input_media_web_page(
|
||||||
const MessageContent *content);
|
const Td *td, const MessageContent *content);
|
||||||
|
|
||||||
void delete_message_content_thumbnail(MessageContent *content, Td *td);
|
void delete_message_content_thumbnail(MessageContent *content, Td *td);
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ void MessageImportManager::on_upload_imported_message_attachment(FileId file_id,
|
|||||||
const PathView path_view(suggested_path);
|
const PathView path_view(suggested_path);
|
||||||
td_->create_handler<UploadImportedMediaQuery>(std::move(promise))
|
td_->create_handler<UploadImportedMediaQuery>(std::move(promise))
|
||||||
->send(dialog_id, import_id, path_view.file_name().str(), file_id,
|
->send(dialog_id, import_id, path_view.file_name().str(), file_id,
|
||||||
get_fake_input_media(td_, std::move(input_file), file_id));
|
get_message_content_fake_input_media(td_, std::move(input_file), file_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageImportManager::on_upload_imported_message_attachment_error(FileId file_id, Status status) {
|
void MessageImportManager::on_upload_imported_message_attachment_error(FileId file_id, Status status) {
|
||||||
|
@ -8350,8 +8350,8 @@ void MessagesManager::do_send_media(DialogId dialog_id, const Message *m, FileId
|
|||||||
content = m->content.get();
|
content = m->content.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto input_media = get_input_media(content, td_, std::move(input_file), std::move(input_thumbnail), file_id,
|
auto input_media = get_message_content_input_media(content, td_, std::move(input_file), std::move(input_thumbnail),
|
||||||
thumbnail_file_id, m->ttl, m->send_emoji, true);
|
file_id, thumbnail_file_id, m->ttl, m->send_emoji, true);
|
||||||
LOG_CHECK(input_media != nullptr) << to_string(get_message_object(dialog_id, m, "do_send_media")) << ' '
|
LOG_CHECK(input_media != nullptr) << to_string(get_message_object(dialog_id, m, "do_send_media")) << ' '
|
||||||
<< have_input_file << ' ' << have_input_thumbnail << ' ' << file_id << ' '
|
<< have_input_file << ' ' << have_input_thumbnail << ' ' << file_id << ' '
|
||||||
<< thumbnail_file_id << ' ' << m->ttl;
|
<< thumbnail_file_id << ' ' << m->ttl;
|
||||||
@ -8375,7 +8375,8 @@ void MessagesManager::do_send_secret_media(DialogId dialog_id, const Message *m,
|
|||||||
auto layer = td_->user_manager_->get_secret_chat_layer(dialog_id.get_secret_chat_id());
|
auto layer = td_->user_manager_->get_secret_chat_layer(dialog_id.get_secret_chat_id());
|
||||||
on_secret_message_media_uploaded(
|
on_secret_message_media_uploaded(
|
||||||
dialog_id, m,
|
dialog_id, m,
|
||||||
get_secret_input_media(m->content.get(), td_, std::move(input_encrypted_file), std::move(thumbnail), layer),
|
get_message_content_secret_input_media(m->content.get(), td_, std::move(input_encrypted_file),
|
||||||
|
std::move(thumbnail), layer),
|
||||||
file_id, thumbnail_file_id);
|
file_id, thumbnail_file_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23981,7 +23982,7 @@ void MessagesManager::do_send_message(DialogId dialog_id, const Message *m, vect
|
|||||||
|
|
||||||
CHECK(!is_edit);
|
CHECK(!is_edit);
|
||||||
auto layer = td_->user_manager_->get_secret_chat_layer(dialog_id.get_secret_chat_id());
|
auto layer = td_->user_manager_->get_secret_chat_layer(dialog_id.get_secret_chat_id());
|
||||||
auto secret_input_media = get_secret_input_media(content, td_, nullptr, BufferSlice(), layer);
|
auto secret_input_media = get_message_content_secret_input_media(content, td_, nullptr, BufferSlice(), layer);
|
||||||
if (secret_input_media.empty()) {
|
if (secret_input_media.empty()) {
|
||||||
LOG(INFO) << "Ask to upload encrypted file " << file_id;
|
LOG(INFO) << "Ask to upload encrypted file " << file_id;
|
||||||
CHECK(file_id.is_valid());
|
CHECK(file_id.is_valid());
|
||||||
@ -23998,8 +23999,8 @@ void MessagesManager::do_send_message(DialogId dialog_id, const Message *m, vect
|
|||||||
on_secret_message_media_uploaded(dialog_id, m, std::move(secret_input_media), file_id, thumbnail_file_id);
|
on_secret_message_media_uploaded(dialog_id, m, std::move(secret_input_media), file_id, thumbnail_file_id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto input_media =
|
auto input_media = get_message_content_input_media(content, td_, m->ttl, m->send_emoji,
|
||||||
get_input_media(content, td_, m->ttl, m->send_emoji, td_->auth_manager_->is_bot() && bad_parts.empty());
|
td_->auth_manager_->is_bot() && bad_parts.empty());
|
||||||
if (file_ids.size() > 1u) {
|
if (file_ids.size() > 1u) {
|
||||||
// TODO PaidMedia
|
// TODO PaidMedia
|
||||||
return;
|
return;
|
||||||
@ -24250,7 +24251,7 @@ void MessagesManager::on_upload_message_media_success(DialogId dialog_id, Messag
|
|||||||
on_message_changed(d, m, need_update, "on_upload_message_media_success");
|
on_message_changed(d, m, need_update, "on_upload_message_media_success");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto input_media = get_input_media(m->content.get(), td_, m->ttl, m->send_emoji, true);
|
auto input_media = get_message_content_input_media(m->content.get(), td_, m->ttl, m->send_emoji, true);
|
||||||
Status result;
|
Status result;
|
||||||
if (input_media == nullptr) {
|
if (input_media == nullptr) {
|
||||||
result = Status::Error(400, "Failed to upload file");
|
result = Status::Error(400, "Failed to upload file");
|
||||||
@ -24426,7 +24427,7 @@ void MessagesManager::do_send_message_group(int64 media_album_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const FormattedText *caption = get_message_content_caption(m->content.get());
|
const FormattedText *caption = get_message_content_caption(m->content.get());
|
||||||
auto input_media = get_input_media(m->content.get(), td_, m->ttl, m->send_emoji, true);
|
auto input_media = get_message_content_input_media(m->content.get(), td_, m->ttl, m->send_emoji, true);
|
||||||
if (input_media == nullptr) {
|
if (input_media == nullptr) {
|
||||||
// TODO return CHECK
|
// TODO return CHECK
|
||||||
auto file_id = get_message_content_any_file_id(m->content.get());
|
auto file_id = get_message_content_any_file_id(m->content.get());
|
||||||
@ -24498,7 +24499,8 @@ void MessagesManager::on_text_message_ready_to_send(DialogId dialog_id, MessageI
|
|||||||
if (dialog_id.get_type() == DialogType::SecretChat) {
|
if (dialog_id.get_type() == DialogType::SecretChat) {
|
||||||
CHECK(!message_id.is_scheduled());
|
CHECK(!message_id.is_scheduled());
|
||||||
auto layer = td_->user_manager_->get_secret_chat_layer(dialog_id.get_secret_chat_id());
|
auto layer = td_->user_manager_->get_secret_chat_layer(dialog_id.get_secret_chat_id());
|
||||||
send_secret_message(dialog_id, m, get_secret_input_media(content, td_, nullptr, BufferSlice(), layer));
|
send_secret_message(dialog_id, m,
|
||||||
|
get_message_content_secret_input_media(content, td_, nullptr, BufferSlice(), layer));
|
||||||
} else {
|
} else {
|
||||||
const FormattedText *message_text = get_message_content_text(content);
|
const FormattedText *message_text = get_message_content_text(content);
|
||||||
CHECK(message_text != nullptr);
|
CHECK(message_text != nullptr);
|
||||||
@ -25047,7 +25049,7 @@ bool MessagesManager::can_resend_message(const Message *m) const {
|
|||||||
auto content_type = m->content->get_type();
|
auto content_type = m->content->get_type();
|
||||||
if (m->via_bot_user_id.is_valid() || m->hide_via_bot) {
|
if (m->via_bot_user_id.is_valid() || m->hide_via_bot) {
|
||||||
// via bot message
|
// via bot message
|
||||||
if (!can_have_input_media(td_, m->content.get(), false)) {
|
if (!can_message_content_have_input_media(td_, m->content.get(), false)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2194,7 +2194,7 @@ void QuickReplyManager::do_send_message(const QuickReplyMessage *m, vector<int>
|
|||||||
FileId file_id = get_message_content_any_file_id(content); // any_file_id, because it could be a photo sent by ID
|
FileId file_id = get_message_content_any_file_id(content); // any_file_id, because it could be a photo sent by ID
|
||||||
FileId thumbnail_file_id = get_message_content_thumbnail_file_id(content, td_);
|
FileId thumbnail_file_id = get_message_content_thumbnail_file_id(content, td_);
|
||||||
LOG(DEBUG) << "Need to send file " << file_id << " with thumbnail " << thumbnail_file_id;
|
LOG(DEBUG) << "Need to send file " << file_id << " with thumbnail " << thumbnail_file_id;
|
||||||
auto input_media = get_input_media(content, td_, {}, m->send_emoji, false);
|
auto input_media = get_message_content_input_media(content, td_, {}, m->send_emoji, false);
|
||||||
if (input_media == nullptr) {
|
if (input_media == nullptr) {
|
||||||
if (content_type == MessageContentType::Game || content_type == MessageContentType::Story) {
|
if (content_type == MessageContentType::Game || content_type == MessageContentType::Story) {
|
||||||
return;
|
return;
|
||||||
@ -2285,8 +2285,8 @@ void QuickReplyManager::do_send_media(const QuickReplyMessage *m, FileId file_id
|
|||||||
|
|
||||||
auto content = m->message_id.is_server() ? m->edited_content.get() : m->content.get();
|
auto content = m->message_id.is_server() ? m->edited_content.get() : m->content.get();
|
||||||
CHECK(content != nullptr);
|
CHECK(content != nullptr);
|
||||||
auto input_media = get_input_media(content, td_, std::move(input_file), std::move(input_thumbnail), file_id,
|
auto input_media = get_message_content_input_media(content, td_, std::move(input_file), std::move(input_thumbnail),
|
||||||
thumbnail_file_id, {}, m->send_emoji, true);
|
file_id, thumbnail_file_id, {}, m->send_emoji, true);
|
||||||
CHECK(input_media != nullptr);
|
CHECK(input_media != nullptr);
|
||||||
|
|
||||||
on_message_media_uploaded(m, std::move(input_media), file_id, thumbnail_file_id);
|
on_message_media_uploaded(m, std::move(input_media), file_id, thumbnail_file_id);
|
||||||
@ -2417,7 +2417,7 @@ void QuickReplyManager::on_upload_message_media_success(QuickReplyShortcutId sho
|
|||||||
|
|
||||||
save_quick_reply_shortcuts();
|
save_quick_reply_shortcuts();
|
||||||
|
|
||||||
auto input_media = get_input_media(content.get(), td_, {}, m->send_emoji, true);
|
auto input_media = get_message_content_input_media(content.get(), td_, {}, m->send_emoji, true);
|
||||||
Status result;
|
Status result;
|
||||||
if (input_media == nullptr) {
|
if (input_media == nullptr) {
|
||||||
result = Status::Error(400, "Failed to upload file");
|
result = Status::Error(400, "Failed to upload file");
|
||||||
@ -2515,7 +2515,7 @@ void QuickReplyManager::do_send_message_group(QuickReplyShortcutId shortcut_id,
|
|||||||
<< " and is_finished = " << static_cast<bool>(request.is_finished[i]);
|
<< " and is_finished = " << static_cast<bool>(request.is_finished[i]);
|
||||||
|
|
||||||
const FormattedText *caption = get_message_content_caption(m->content.get());
|
const FormattedText *caption = get_message_content_caption(m->content.get());
|
||||||
auto input_media = get_input_media(m->content.get(), td_, {}, m->send_emoji, true);
|
auto input_media = get_message_content_input_media(m->content.get(), td_, {}, m->send_emoji, true);
|
||||||
CHECK(input_media != nullptr);
|
CHECK(input_media != nullptr);
|
||||||
auto entities = get_input_message_entities(td_->user_manager_.get(), caption, "do_send_message_group");
|
auto entities = get_input_message_entities(td_->user_manager_.get(), caption, "do_send_message_group");
|
||||||
int32 input_single_media_flags = 0;
|
int32 input_single_media_flags = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user