Use dup_photo in dup_story_content.
This commit is contained in:
parent
c304bb12d6
commit
031864db3e
@ -392,6 +392,8 @@ Result<Photo> create_photo(FileManager *file_manager, FileId file_id, PhotoSize
|
||||
}
|
||||
|
||||
Photo dup_photo(Photo photo) {
|
||||
CHECK(!photo.photos.empty());
|
||||
|
||||
// Find 'i' or largest
|
||||
PhotoSize input_size;
|
||||
for (const auto &size : photo.photos) {
|
||||
|
@ -429,31 +429,12 @@ unique_ptr<StoryContent> dup_story_content(Td *td, const StoryContent *content)
|
||||
switch (content->get_type()) {
|
||||
case StoryContentType::Photo: {
|
||||
const auto *old_content = static_cast<const StoryContentPhoto *>(content);
|
||||
// Find 'i' or largest
|
||||
PhotoSize photo_size;
|
||||
for (const auto &size : old_content->photo_.photos) {
|
||||
if (size.type == 'i') {
|
||||
photo_size = size;
|
||||
}
|
||||
auto photo = dup_photo(old_content->photo_);
|
||||
photo.photos.back().file_id = fix_file_id(photo.photos.back().file_id);
|
||||
if (photo.photos.size() > 1) {
|
||||
photo.photos[0].file_id = fix_file_id(photo.photos[0].file_id);
|
||||
}
|
||||
if (photo_size.type == 0) {
|
||||
for (const auto &size : old_content->photo_.photos) {
|
||||
if (photo_size.type == 0 || photo_size < size) {
|
||||
photo_size = size;
|
||||
}
|
||||
}
|
||||
}
|
||||
photo_size.type = 'i';
|
||||
photo_size.file_id = fix_file_id(photo_size.file_id);
|
||||
|
||||
auto result = make_unique<StoryContentPhoto>(Photo(old_content->photo_));
|
||||
|
||||
result->photo_.photos.clear();
|
||||
result->photo_.animations.clear();
|
||||
result->photo_.sticker_photo_size = nullptr;
|
||||
|
||||
result->photo_.photos.push_back(std::move(photo_size));
|
||||
return std::move(result);
|
||||
return make_unique<StoryContentPhoto>(std::move(photo));
|
||||
}
|
||||
case StoryContentType::Video: {
|
||||
const auto *old_content = static_cast<const StoryContentVideo *>(content);
|
||||
|
Loading…
Reference in New Issue
Block a user