Support for MessageGame in get_message_content_file_ids.

GitOrigin-RevId: 90a6701206121dd37e1bd3dcca57d94ce5473085
This commit is contained in:
levlam 2019-01-06 02:15:07 +03:00
parent 027c1eafc4
commit b740d3dab0
5 changed files with 19 additions and 2 deletions

View File

@ -84,6 +84,14 @@ UserId Game::get_bot_user_id() const {
return bot_user_id_;
}
vector<FileId> Game::get_file_ids() const {
auto result = photo_get_file_ids(photo_);
if (animation_file_id_.is_valid()) {
result.push_back(animation_file_id_);
}
return result;
}
void Game::set_text(FormattedText &&text) {
text_ = std::move(text);
}

View File

@ -57,6 +57,8 @@ class Game {
UserId get_bot_user_id() const;
vector<FileId> get_file_ids() const;
void set_text(FormattedText &&text);
const FormattedText &get_text() const;

View File

@ -4417,8 +4417,7 @@ FileId get_message_content_thumbnail_file_id(const MessageContent *content, cons
vector<FileId> get_message_content_file_ids(const MessageContent *content, const Td *td) {
switch (content->get_type()) {
case MessageContentType::Photo:
return transform(static_cast<const MessagePhoto *>(content)->photo.photos,
[](auto &size) { return size.file_id; });
return photo_get_file_ids(static_cast<const MessagePhoto *>(content)->photo);
case MessageContentType::Animation:
case MessageContentType::Audio:
case MessageContentType::Document:
@ -4438,6 +4437,8 @@ vector<FileId> get_message_content_file_ids(const MessageContent *content, const
}
return result;
}
case MessageContentType::Game:
return static_cast<const MessageGame *>(content)->game.get_file_ids();
default:
return {};
}

View File

@ -637,6 +637,10 @@ SecretInputMedia photo_get_secret_input_media(FileManager *file_manager, const P
BufferSlice(encryption_key.key_slice()), BufferSlice(encryption_key.iv_slice()), caption)};
}
vector<FileId> photo_get_file_ids(const Photo &photo) {
return transform(photo.photos, [](auto &size) { return size.file_id; });
}
bool operator==(const Photo &lhs, const Photo &rhs) {
return lhs.id == rhs.id && lhs.photos == rhs.photos;
}

View File

@ -114,6 +114,8 @@ tl_object_ptr<telegram_api::InputMedia> photo_get_input_media(FileManager *file_
tl_object_ptr<telegram_api::InputFile> input_file,
int32 ttl);
vector<FileId> photo_get_file_ids(const Photo &photo);
bool operator==(const Photo &lhs, const Photo &rhs);
bool operator!=(const Photo &lhs, const Photo &rhs);