Add copy_story_content function.

This commit is contained in:
levlam 2023-05-29 20:48:31 +03:00
parent 77ab0f45c1
commit e169cfc7f7
2 changed files with 25 additions and 0 deletions

View File

@ -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) { td_api::object_ptr<td_api::StoryContent> get_story_content_object(Td *td, const StoryContent *content) {
CHECK(content != nullptr); CHECK(content != nullptr);
switch (content->get_type()) { switch (content->get_type()) {

View File

@ -43,6 +43,8 @@ telegram_api::object_ptr<telegram_api::InputMedia> get_story_content_input_media
void merge_story_contents(Td *td, const StoryContent *old_content, StoryContent *new_content, DialogId dialog_id, void merge_story_contents(Td *td, const StoryContent *old_content, StoryContent *new_content, DialogId dialog_id,
bool need_merge_files, bool &is_content_changed, bool &need_update); bool need_merge_files, bool &is_content_changed, bool &need_update);
unique_ptr<StoryContent> copy_story_content(const StoryContent *content);
td_api::object_ptr<td_api::StoryContent> get_story_content_object(Td *td, const StoryContent *content); td_api::object_ptr<td_api::StoryContent> get_story_content_object(Td *td, const StoryContent *content);
FileId get_story_content_any_file_id(const Td *td, const StoryContent *content); FileId get_story_content_any_file_id(const Td *td, const StoryContent *content);