Support merge_message_contents for PaidMedia.
This commit is contained in:
parent
5e3189f984
commit
d93d5a535f
@ -4735,10 +4735,14 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
|
||||
break;
|
||||
}
|
||||
case MessageContentType::PaidMedia: {
|
||||
//const auto *old_ = static_cast<const MessagePaidMedia *>(old_content);
|
||||
//const auto *new_ = static_cast<const MessagePaidMedia *>(new_content);
|
||||
if (need_merge_files) {
|
||||
// TODO merge extended media
|
||||
const auto *old_ = static_cast<const MessagePaidMedia *>(old_content);
|
||||
auto *new_ = static_cast<MessagePaidMedia *>(new_content);
|
||||
if (old_->media.size() != new_->media.size()) {
|
||||
LOG(ERROR) << "Had " << old_->media.size() << " paid media, but now have " << new_->media.size();
|
||||
} else {
|
||||
for (size_t i = 0; i < old_->media.size(); i++) {
|
||||
old_->media[i].merge_files(td, new_->media[i], dialog_id, need_merge_files, is_content_changed, need_update);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -394,6 +394,33 @@ telegram_api::object_ptr<telegram_api::InputMedia> MessageExtendedMedia::get_inp
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MessageExtendedMedia::merge_files(Td *td, MessageExtendedMedia &other, DialogId dialog_id, bool need_merge_files,
|
||||
bool &is_content_changed, bool &need_update) const {
|
||||
if (!has_input_media() || !other.has_input_media()) {
|
||||
return;
|
||||
}
|
||||
if (type_ != other.type_) {
|
||||
LOG(ERROR) << "Type of a paid media has changed";
|
||||
return;
|
||||
}
|
||||
switch (type_) {
|
||||
case Type::Photo:
|
||||
merge_photos(td, &photo_, &other.photo_, dialog_id, need_merge_files, is_content_changed, need_update);
|
||||
break;
|
||||
case Type::Video:
|
||||
if (video_file_id_ != other.video_file_id_ && need_merge_files) {
|
||||
td->videos_manager_->merge_videos(other.video_file_id_, video_file_id_);
|
||||
}
|
||||
break;
|
||||
case Type::Empty:
|
||||
case Type::Preview:
|
||||
case Type::Unsupported:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool MessageExtendedMedia::is_equal_but_different(const MessageExtendedMedia &other) const {
|
||||
return type_ == Type::Unsupported && other.type_ == Type::Unsupported &&
|
||||
unsupported_version_ != other.unsupported_version_;
|
||||
|
@ -108,6 +108,9 @@ class MessageExtendedMedia {
|
||||
Td *td, tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail) const;
|
||||
|
||||
void merge_files(Td *td, MessageExtendedMedia &other, DialogId dialog_id, bool need_merge_files,
|
||||
bool &is_content_changed, bool &need_update) const;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user