Never replace ExtendedMedia media with preview.

This commit is contained in:
levlam 2022-09-22 06:39:40 +03:00
parent a7d8d28895
commit 2440ebda56
3 changed files with 14 additions and 1 deletions

View File

@ -3219,7 +3219,8 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
} }
case MessageContentType::Invoice: { case MessageContentType::Invoice: {
const auto *old_ = static_cast<const MessageInvoice *>(old_content); const auto *old_ = static_cast<const MessageInvoice *>(old_content);
const auto *new_ = static_cast<const MessageInvoice *>(new_content); auto *new_ = static_cast<MessageInvoice *>(new_content);
new_->input_invoice.extended_media.update_from(old_->input_invoice.extended_media);
if (old_->input_invoice != new_->input_invoice) { if (old_->input_invoice != new_->input_invoice) {
need_update = true; need_update = true;
} }

View File

@ -89,6 +89,12 @@ MessageExtendedMedia::MessageExtendedMedia(
} }
} }
void MessageExtendedMedia::update_from(const MessageExtendedMedia &old_extended_media) {
if (!is_media() && old_extended_media.is_media()) {
*this = old_extended_media;
}
}
td_api::object_ptr<td_api::MessageExtendedMedia> MessageExtendedMedia::get_message_extended_media_object( td_api::object_ptr<td_api::MessageExtendedMedia> MessageExtendedMedia::get_message_extended_media_object(
Td *td, bool skip_bot_commands, int32 max_media_timestamp) const { Td *td, bool skip_bot_commands, int32 max_media_timestamp) const {
if (type_ == Type::Empty) { if (type_ == Type::Empty) {

View File

@ -36,6 +36,10 @@ class MessageExtendedMedia {
friend bool operator==(const MessageExtendedMedia &lhs, const MessageExtendedMedia &rhs); friend bool operator==(const MessageExtendedMedia &lhs, const MessageExtendedMedia &rhs);
bool is_media() const {
return type_ != Type::Empty && type_ != Type::Preview;
}
public: public:
MessageExtendedMedia() = default; MessageExtendedMedia() = default;
@ -46,6 +50,8 @@ class MessageExtendedMedia {
return type_ == Type::Empty; return type_ == Type::Empty;
} }
void update_from(const MessageExtendedMedia &old_extended_media);
td_api::object_ptr<td_api::MessageExtendedMedia> get_message_extended_media_object(Td *td, bool skip_bot_commands, td_api::object_ptr<td_api::MessageExtendedMedia> get_message_extended_media_object(Td *td, bool skip_bot_commands,
int32 max_media_timestamp) const; int32 max_media_timestamp) const;