Add create_photo function.
This commit is contained in:
parent
3d4b4ac014
commit
fc82657626
@ -2076,32 +2076,11 @@ static Result<InputMessageContent> create_input_message_content(
|
||||
|
||||
ttl = input_photo->self_destruct_time_;
|
||||
|
||||
TRY_RESULT(input_photo_size,
|
||||
get_input_photo_size(td->file_manager_.get(), file_id, input_photo->width_, input_photo->height_));
|
||||
TRY_RESULT(photo, create_photo(td->file_manager_.get(), file_id, std::move(thumbnail), input_photo->width_,
|
||||
input_photo->height_, std::move(sticker_file_ids)));
|
||||
|
||||
auto message_photo = make_unique<MessagePhoto>();
|
||||
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
||||
message_photo->photo.id = file_view.remote_location().get_id();
|
||||
}
|
||||
if (message_photo->photo.is_empty()) {
|
||||
message_photo->photo.id = 0;
|
||||
}
|
||||
message_photo->photo.date = G()->unix_time();
|
||||
|
||||
if (thumbnail.file_id.is_valid()) {
|
||||
message_photo->photo.photos.push_back(std::move(thumbnail));
|
||||
}
|
||||
|
||||
message_photo->photo.photos.push_back(std::move(input_photo_size));
|
||||
|
||||
message_photo->photo.has_stickers = !sticker_file_ids.empty();
|
||||
message_photo->photo.sticker_file_ids = std::move(sticker_file_ids);
|
||||
|
||||
message_photo->caption = std::move(caption);
|
||||
message_photo->has_spoiler = input_photo->has_spoiler_ && !is_secret;
|
||||
|
||||
content = std::move(message_photo);
|
||||
content =
|
||||
make_unique<MessagePhoto>(std::move(photo), std::move(caption), input_photo->has_spoiler_ && !is_secret);
|
||||
break;
|
||||
}
|
||||
case td_api::inputMessageSticker::ID: {
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/PhotoFormat.h"
|
||||
#include "td/telegram/PhotoSizeSource.h"
|
||||
@ -367,6 +368,28 @@ Photo get_web_document_photo(FileManager *file_manager, tl_object_ptr<telegram_a
|
||||
return photo;
|
||||
}
|
||||
|
||||
Result<Photo> create_photo(FileManager *file_manager, FileId file_id, PhotoSize &&thumbnail, int32 width, int32 height,
|
||||
vector<FileId> &&sticker_file_ids) {
|
||||
TRY_RESULT(input_photo_size, get_input_photo_size(file_manager, file_id, width, height));
|
||||
|
||||
Photo photo;
|
||||
auto file_view = file_manager->get_file_view(file_id);
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
||||
photo.id = file_view.remote_location().get_id();
|
||||
}
|
||||
if (photo.is_empty()) {
|
||||
photo.id = 0;
|
||||
}
|
||||
photo.date = G()->unix_time();
|
||||
if (thumbnail.file_id.is_valid()) {
|
||||
photo.photos.push_back(std::move(thumbnail));
|
||||
}
|
||||
photo.photos.push_back(std::move(input_photo_size));
|
||||
photo.has_stickers = !sticker_file_ids.empty();
|
||||
photo.sticker_file_ids = std::move(sticker_file_ids);
|
||||
return photo;
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::photo> get_photo_object(FileManager *file_manager, const Photo &photo) {
|
||||
if (photo.is_empty()) {
|
||||
return nullptr;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/MovableValue.h"
|
||||
#include "td/utils/Status.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
#include "td/utils/unique_value_ptr.h"
|
||||
|
||||
@ -104,12 +105,20 @@ bool need_update_dialog_photo(const DialogPhoto &from, const DialogPhoto &to);
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const DialogPhoto &dialog_photo);
|
||||
|
||||
Photo get_photo(Td *td, tl_object_ptr<telegram_api::Photo> &&photo, DialogId owner_dialog_id);
|
||||
|
||||
Photo get_photo(Td *td, tl_object_ptr<telegram_api::photo> &&photo, DialogId owner_dialog_id);
|
||||
|
||||
Photo get_encrypted_file_photo(FileManager *file_manager, unique_ptr<EncryptedFile> &&file,
|
||||
tl_object_ptr<secret_api::decryptedMessageMediaPhoto> &&photo, DialogId owner_dialog_id);
|
||||
|
||||
Photo get_web_document_photo(FileManager *file_manager, tl_object_ptr<telegram_api::WebDocument> web_document,
|
||||
DialogId owner_dialog_id);
|
||||
|
||||
Result<Photo> create_photo(FileManager *file_manager, FileId file_id, PhotoSize &&thumbnail, int32 width, int32 height,
|
||||
vector<FileId> &&sticker_file_ids);
|
||||
|
||||
tl_object_ptr<td_api::photo> get_photo_object(FileManager *file_manager, const Photo &photo);
|
||||
|
||||
tl_object_ptr<td_api::chatPhoto> get_chat_photo_object(FileManager *file_manager, const Photo &photo);
|
||||
|
||||
void merge_photos(Td *td, const Photo *old_photo, Photo *new_photo, DialogId dialog_id, bool need_merge_files,
|
||||
|
Loading…
Reference in New Issue
Block a user