Add get_individual_message_contents.
This commit is contained in:
parent
2c6d9a000f
commit
a0d0b66164
@ -2759,6 +2759,14 @@ unique_ptr<MessageContent> create_text_message_content(string text, vector<Messa
|
||||
force_small_media, force_large_media, skip_confirmation, std::move(web_page_url));
|
||||
}
|
||||
|
||||
unique_ptr<MessageContent> create_photo_message_content(Photo photo) {
|
||||
return make_unique<MessagePhoto>(std::move(photo), FormattedText(), false);
|
||||
}
|
||||
|
||||
unique_ptr<MessageContent> create_video_message_content(FileId file_id) {
|
||||
return make_unique<MessageVideo>(file_id, FormattedText(), false);
|
||||
}
|
||||
|
||||
unique_ptr<MessageContent> create_contact_registered_message_content() {
|
||||
return make_unique<MessageContactRegistered>();
|
||||
}
|
||||
@ -4333,6 +4341,12 @@ int32 get_message_content_index_mask(const MessageContent *content, const Td *td
|
||||
return get_message_content_text_index_mask(content) | get_message_content_media_index_mask(content, td, is_outgoing);
|
||||
}
|
||||
|
||||
vector<unique_ptr<MessageContent>> get_individual_message_contents(const MessageContent *content) {
|
||||
CHECK(content->get_type() == MessageContentType::PaidMedia);
|
||||
const auto *m = static_cast<const MessagePaidMedia *>(content);
|
||||
return transform(m->media, [](const MessageExtendedMedia &media) { return media.get_message_content(); });
|
||||
}
|
||||
|
||||
StickerType get_message_content_sticker_type(const Td *td, const MessageContent *content) {
|
||||
CHECK(content->get_type() == MessageContentType::Sticker);
|
||||
return td->stickers_manager_->get_sticker_type(static_cast<const MessageSticker *>(content)->file_id);
|
||||
@ -6839,7 +6853,7 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
|
||||
}
|
||||
if (type != MessageContentDupType::Forward) {
|
||||
for (auto &media : result->media) {
|
||||
media = media.dup_to_send(td, result->media.size() > 1u);
|
||||
media = media.dup_to_send(td, true);
|
||||
CHECK(!media.is_empty());
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +105,10 @@ unique_ptr<MessageContent> create_text_message_content(string text, vector<Messa
|
||||
bool force_large_media, bool skip_confitmation,
|
||||
string &&web_page_url);
|
||||
|
||||
unique_ptr<MessageContent> create_photo_message_content(Photo photo);
|
||||
|
||||
unique_ptr<MessageContent> create_video_message_content(FileId file_id);
|
||||
|
||||
unique_ptr<MessageContent> create_contact_registered_message_content();
|
||||
|
||||
unique_ptr<MessageContent> create_screenshot_taken_message_content();
|
||||
@ -157,6 +161,8 @@ bool update_opened_message_content(MessageContent *content);
|
||||
|
||||
int32 get_message_content_index_mask(const MessageContent *content, const Td *td, bool is_outgoing);
|
||||
|
||||
vector<unique_ptr<MessageContent>> get_individual_message_contents(const MessageContent *content);
|
||||
|
||||
StickerType get_message_content_sticker_type(const Td *td, const MessageContent *content);
|
||||
|
||||
MessageId get_message_content_pinned_message_id(const MessageContent *content);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "td/telegram/DocumentsManager.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/MessageContent.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
#include "td/telegram/PhotoSize.h"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
@ -258,6 +259,21 @@ void MessageExtendedMedia::delete_thumbnail(Td *td) {
|
||||
}
|
||||
}
|
||||
|
||||
unique_ptr<MessageContent> MessageExtendedMedia::get_message_content() const {
|
||||
switch (type_) {
|
||||
case Type::Photo:
|
||||
return create_photo_message_content(photo_);
|
||||
case Type::Video:
|
||||
return create_video_message_content(video_file_id_);
|
||||
case Type::Empty:
|
||||
case Type::Unsupported:
|
||||
case Type::Preview:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
int32 MessageExtendedMedia::get_duration(const Td *td) const {
|
||||
if (!has_media_timestamp()) {
|
||||
return -1;
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class MessageContent;
|
||||
|
||||
class Td;
|
||||
|
||||
class MessageExtendedMedia {
|
||||
@ -92,6 +94,8 @@ class MessageExtendedMedia {
|
||||
|
||||
bool is_equal_but_different(const MessageExtendedMedia &other) const;
|
||||
|
||||
unique_ptr<MessageContent> get_message_content() const;
|
||||
|
||||
int32 get_duration(const Td *td) const;
|
||||
|
||||
FileId get_upload_file_id() const;
|
||||
|
Loading…
Reference in New Issue
Block a user