Fix spoiler in on_upload_message_media_success.

This commit is contained in:
levlam 2022-12-30 02:39:31 +03:00
parent 2a0f211dfe
commit e4c8eb376e
3 changed files with 35 additions and 0 deletions

View File

@ -5669,6 +5669,35 @@ const FormattedText *get_message_content_caption(const MessageContent *content)
}
}
bool get_message_content_has_spoiler(const MessageContent *content) {
switch (content->get_type()) {
case MessageContentType::Animation:
return static_cast<const MessageAnimation *>(content)->has_spoiler;
case MessageContentType::Photo:
return static_cast<const MessagePhoto *>(content)->has_spoiler;
case MessageContentType::Video:
return static_cast<const MessageVideo *>(content)->has_spoiler;
default:
return false;
}
}
void set_message_content_has_spoiler(MessageContent *content, bool has_spoiler) {
switch (content->get_type()) {
case MessageContentType::Animation:
static_cast<MessageAnimation *>(content)->has_spoiler = has_spoiler;
break;
case MessageContentType::Photo:
static_cast<MessagePhoto *>(content)->has_spoiler = has_spoiler;
break;
case MessageContentType::Video:
static_cast<MessageVideo *>(content)->has_spoiler = has_spoiler;
break;
default:
break;
}
}
int32 get_message_content_duration(const MessageContent *content, const Td *td) {
CHECK(content != nullptr);
switch (content->get_type()) {

View File

@ -212,6 +212,10 @@ const FormattedText *get_message_content_text(const MessageContent *content);
const FormattedText *get_message_content_caption(const MessageContent *content);
bool get_message_content_has_spoiler(const MessageContent *content);
void set_message_content_has_spoiler(MessageContent *content, bool has_spoiler);
int32 get_message_content_duration(const MessageContent *content, const Td *td);
int32 get_message_content_media_duration(const MessageContent *content, const Td *td);

View File

@ -26825,8 +26825,10 @@ void MessagesManager::on_upload_message_media_success(DialogId dialog_id, Messag
}
auto caption = get_message_content_caption(m->content.get());
auto has_spoiler = get_message_content_has_spoiler(m->content.get());
auto content = get_message_content(td_, caption == nullptr ? FormattedText() : *caption, std::move(media), dialog_id,
false, UserId(), nullptr, nullptr, "on_upload_message_media_success");
set_message_content_has_spoiler(content.get(), has_spoiler);
bool is_content_changed = false;
bool need_update = update_message_content(dialog_id, m, std::move(content), true, true, is_content_changed);