Support updateMessageExtendedMedia for PaidMedia.
This commit is contained in:
parent
d0bc0ccfd8
commit
a865253feb
@ -8086,13 +8086,36 @@ bool update_message_content_extended_media(
|
||||
MessageContent *content, vector<telegram_api::object_ptr<telegram_api::MessageExtendedMedia>> extended_media,
|
||||
DialogId owner_dialog_id, Td *td) {
|
||||
CHECK(content != nullptr);
|
||||
CHECK(content->get_type() == MessageContentType::Invoice);
|
||||
if (extended_media.size() != 1) {
|
||||
LOG(ERROR) << "Receive " << extended_media.size() << " extended media in " << owner_dialog_id;
|
||||
return false;
|
||||
switch (content->get_type()) {
|
||||
case MessageContentType::Invoice:
|
||||
if (extended_media.size() != 1) {
|
||||
LOG(ERROR) << "Receive " << extended_media.size() << " extended media in " << owner_dialog_id;
|
||||
return false;
|
||||
}
|
||||
return static_cast<MessageInvoice *>(content)->input_invoice.update_extended_media(std::move(extended_media[0]),
|
||||
owner_dialog_id, td);
|
||||
case MessageContentType::PaidMedia: {
|
||||
auto &media = static_cast<MessagePaidMedia *>(content)->media;
|
||||
if (extended_media.size() != media.size()) {
|
||||
LOG(ERROR) << "Receive " << extended_media.size() << " paid media instead of " << media.size() << " in "
|
||||
<< owner_dialog_id;
|
||||
return false;
|
||||
}
|
||||
bool result = false;
|
||||
for (size_t i = 0; i < media.size(); i++) {
|
||||
if (media[i].update_to(td, std::move(extended_media[i]), owner_dialog_id)) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
case MessageContentType::Unsupported:
|
||||
return false;
|
||||
default:
|
||||
LOG(ERROR) << "Receive updateMessageExtendedMedia for a message of type " << content->get_type() << " in "
|
||||
<< owner_dialog_id;
|
||||
return false;
|
||||
}
|
||||
return static_cast<MessageInvoice *>(content)->input_invoice.update_extended_media(std::move(extended_media[0]),
|
||||
owner_dialog_id, td);
|
||||
}
|
||||
|
||||
bool need_poll_message_content_extended_media(const MessageContent *content) {
|
||||
|
@ -6786,15 +6786,7 @@ void MessagesManager::on_update_message_extended_media(
|
||||
return;
|
||||
}
|
||||
|
||||
auto content = m->content.get();
|
||||
auto content_type = content->get_type();
|
||||
if (content_type != MessageContentType::Invoice) {
|
||||
if (content_type != MessageContentType::Unsupported) {
|
||||
LOG(ERROR) << "Receive updateMessageExtendedMedia for " << message_full_id << " of type " << content_type;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (update_message_content_extended_media(content, std::move(extended_media), dialog_id, td_)) {
|
||||
if (update_message_content_extended_media(m->content.get(), std::move(extended_media), dialog_id, td_)) {
|
||||
send_update_message_content(d, m, true, "on_update_message_extended_media 3");
|
||||
on_message_changed(d, m, true, "on_update_message_extended_media 4");
|
||||
on_message_notification_changed(d, m, "on_update_message_extended_media 5"); // usually a no-op
|
||||
|
Loading…
Reference in New Issue
Block a user