Add version for MessageExtendedMedia::Unsupported.
This commit is contained in:
parent
2440ebda56
commit
1fd5452c8f
@ -3224,6 +3224,10 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
|
|||||||
if (old_->input_invoice != new_->input_invoice) {
|
if (old_->input_invoice != new_->input_invoice) {
|
||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
|
if (old_->input_invoice.extended_media.get_unsupported_version() !=
|
||||||
|
new_->input_invoice.extended_media.get_unsupported_version()) {
|
||||||
|
is_content_changed = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageContentType::LiveLocation: {
|
case MessageContentType::LiveLocation: {
|
||||||
@ -5716,6 +5720,10 @@ bool need_reget_message_content(const MessageContent *content) {
|
|||||||
const auto *m = static_cast<const MessageUnsupported *>(content);
|
const auto *m = static_cast<const MessageUnsupported *>(content);
|
||||||
return m->version != MessageUnsupported::CURRENT_VERSION;
|
return m->version != MessageUnsupported::CURRENT_VERSION;
|
||||||
}
|
}
|
||||||
|
case MessageContentType::Invoice: {
|
||||||
|
const auto *m = static_cast<const MessageInvoice *>(content);
|
||||||
|
return m->input_invoice.extended_media.need_reget();
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,9 @@ MessageExtendedMedia::MessageExtendedMedia(
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (type_ == Type::Unsupported) {
|
||||||
|
unsupported_version_ = CURRENT_VERSION;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -23,6 +23,11 @@ class MessageExtendedMedia {
|
|||||||
Type type_ = Type::Empty;
|
Type type_ = Type::Empty;
|
||||||
FormattedText caption_;
|
FormattedText caption_;
|
||||||
|
|
||||||
|
static constexpr int32 CURRENT_VERSION = 1;
|
||||||
|
|
||||||
|
// for Unsupported
|
||||||
|
int32 unsupported_version_ = 0;
|
||||||
|
|
||||||
// for Preview
|
// for Preview
|
||||||
int32 duration_ = 0;
|
int32 duration_ = 0;
|
||||||
Dimensions dimensions_;
|
Dimensions dimensions_;
|
||||||
@ -57,6 +62,14 @@ class MessageExtendedMedia {
|
|||||||
|
|
||||||
void append_file_ids(const Td *td, vector<FileId> &file_ids) const;
|
void append_file_ids(const Td *td, vector<FileId> &file_ids) const;
|
||||||
|
|
||||||
|
int32 get_unsupported_version() const {
|
||||||
|
return unsupported_version_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool need_reget() const {
|
||||||
|
return type_ == Type::Unsupported && unsupported_version_ < CURRENT_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void store(StorerT &storer) const;
|
void store(StorerT &storer) const;
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ namespace td {
|
|||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void MessageExtendedMedia::store(StorerT &storer) const {
|
void MessageExtendedMedia::store(StorerT &storer) const {
|
||||||
bool has_caption = !caption_.text.empty();
|
bool has_caption = !caption_.text.empty();
|
||||||
|
bool has_unsupported_version = unsupported_version_ != 0;
|
||||||
bool has_duration = duration_ != 0;
|
bool has_duration = duration_ != 0;
|
||||||
bool has_dimensions = dimensions_.width != 0 || dimensions_.height != 0;
|
bool has_dimensions = dimensions_.width != 0 || dimensions_.height != 0;
|
||||||
bool has_minithumbnail = !minithumbnail_.empty();
|
bool has_minithumbnail = !minithumbnail_.empty();
|
||||||
@ -25,6 +26,7 @@ void MessageExtendedMedia::store(StorerT &storer) const {
|
|||||||
bool has_video = video_file_id_.is_valid();
|
bool has_video = video_file_id_.is_valid();
|
||||||
BEGIN_STORE_FLAGS();
|
BEGIN_STORE_FLAGS();
|
||||||
STORE_FLAG(has_caption);
|
STORE_FLAG(has_caption);
|
||||||
|
STORE_FLAG(has_unsupported_version);
|
||||||
STORE_FLAG(has_duration);
|
STORE_FLAG(has_duration);
|
||||||
STORE_FLAG(has_dimensions);
|
STORE_FLAG(has_dimensions);
|
||||||
STORE_FLAG(has_minithumbnail);
|
STORE_FLAG(has_minithumbnail);
|
||||||
@ -35,6 +37,9 @@ void MessageExtendedMedia::store(StorerT &storer) const {
|
|||||||
if (has_caption) {
|
if (has_caption) {
|
||||||
td::store(caption_, storer);
|
td::store(caption_, storer);
|
||||||
}
|
}
|
||||||
|
if (has_unsupported_version) {
|
||||||
|
td::store(unsupported_version_, storer);
|
||||||
|
}
|
||||||
if (has_duration) {
|
if (has_duration) {
|
||||||
td::store(duration_, storer);
|
td::store(duration_, storer);
|
||||||
}
|
}
|
||||||
@ -56,6 +61,7 @@ void MessageExtendedMedia::store(StorerT &storer) const {
|
|||||||
template <class ParserT>
|
template <class ParserT>
|
||||||
void MessageExtendedMedia::parse(ParserT &parser) {
|
void MessageExtendedMedia::parse(ParserT &parser) {
|
||||||
bool has_caption;
|
bool has_caption;
|
||||||
|
bool has_unsupported_version;
|
||||||
bool has_duration;
|
bool has_duration;
|
||||||
bool has_dimensions;
|
bool has_dimensions;
|
||||||
bool has_minithumbnail;
|
bool has_minithumbnail;
|
||||||
@ -63,6 +69,7 @@ void MessageExtendedMedia::parse(ParserT &parser) {
|
|||||||
bool has_video;
|
bool has_video;
|
||||||
BEGIN_PARSE_FLAGS();
|
BEGIN_PARSE_FLAGS();
|
||||||
PARSE_FLAG(has_caption);
|
PARSE_FLAG(has_caption);
|
||||||
|
PARSE_FLAG(has_unsupported_version);
|
||||||
PARSE_FLAG(has_duration);
|
PARSE_FLAG(has_duration);
|
||||||
PARSE_FLAG(has_dimensions);
|
PARSE_FLAG(has_dimensions);
|
||||||
PARSE_FLAG(has_minithumbnail);
|
PARSE_FLAG(has_minithumbnail);
|
||||||
@ -73,6 +80,9 @@ void MessageExtendedMedia::parse(ParserT &parser) {
|
|||||||
if (has_caption) {
|
if (has_caption) {
|
||||||
td::parse(caption_, parser);
|
td::parse(caption_, parser);
|
||||||
}
|
}
|
||||||
|
if (has_unsupported_version) {
|
||||||
|
td::parse(unsupported_version_, parser);
|
||||||
|
}
|
||||||
if (has_duration) {
|
if (has_duration) {
|
||||||
td::parse(duration_, parser);
|
td::parse(duration_, parser);
|
||||||
}
|
}
|
||||||
@ -104,6 +114,7 @@ void MessageExtendedMedia::parse(ParserT &parser) {
|
|||||||
photo_ = Photo();
|
photo_ = Photo();
|
||||||
video_file_id_ = FileId();
|
video_file_id_ = FileId();
|
||||||
type_ = Type::Unsupported;
|
type_ = Type::Unsupported;
|
||||||
|
unsupported_version_ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user