diff options
| author | levlam <levlam@telegram.org> | 2023-05-29 20:48:31 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2023-05-29 20:48:31 +0300 |
| commit | e169cfc7f7eb8dd453b83d8072e618011318ad7a (patch) | |
| tree | cfff211b9401e42df1dbf1e676dab710637c0c64 /td/telegram/StoryContent.cpp | |
| parent | 77ab0f45c10fae66ace8c88d9e0c817185badaaa (diff) | |
Add copy_story_content function.
Diffstat (limited to 'td/telegram/StoryContent.cpp')
| -rw-r--r-- | td/telegram/StoryContent.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/td/telegram/StoryContent.cpp b/td/telegram/StoryContent.cpp index 3501e2e5d..1f1f64777 100644 --- a/td/telegram/StoryContent.cpp +++ b/td/telegram/StoryContent.cpp @@ -232,6 +232,29 @@ void merge_story_contents(Td *td, const StoryContent *old_content, StoryContent } } +unique_ptr<StoryContent> copy_story_content(const StoryContent *content) { + if (content == nullptr) { + return nullptr; + } + switch (content->get_type()) { + case StoryContentType::Photo: { + const auto *story_content = static_cast<const StoryContentPhoto *>(content); + return make_unique<StoryContentPhoto>(Photo(story_content->photo_)); + } + case StoryContentType::Video: { + const auto *story_content = static_cast<const StoryContentVideo *>(content); + return make_unique<StoryContentVideo>(story_content->file_id_, story_content->alt_file_id_); + } + case StoryContentType::Unsupported: { + const auto *story_content = static_cast<const StoryContentUnsupported *>(content); + return make_unique<StoryContentUnsupported>(story_content->version_); + } + default: + UNREACHABLE(); + return nullptr; + } +} + td_api::object_ptr<td_api::StoryContent> get_story_content_object(Td *td, const StoryContent *content) { CHECK(content != nullptr); switch (content->get_type()) { |
