Add get_expired_message_content_type.

This commit is contained in:
levlam 2024-06-21 14:00:29 +03:00
parent f3c52beaba
commit 3d0f92e0cb
3 changed files with 20 additions and 7 deletions

View File

@ -158,7 +158,7 @@ bool is_allowed_invert_caption_message_content(MessageContentType content_type)
case MessageContentType::Video:
return true;
default:
return false;
return false;
}
}
@ -522,6 +522,21 @@ bool is_expired_message_content(MessageContentType content_type) {
}
}
MessageContentType get_expired_message_content_type(MessageContentType content_type) {
switch (content_type) {
case MessageContentType::Photo:
return MessageContentType::ExpiredPhoto;
case MessageContentType::Video:
return MessageContentType::ExpiredVideo;
case MessageContentType::VideoNote:
return MessageContentType::ExpiredVideoNote;
case MessageContentType::VoiceNote:
return MessageContentType::ExpiredVoiceNote;
default:
return MessageContentType::None;
}
}
bool can_have_message_content_caption(MessageContentType content_type) {
switch (content_type) {
case MessageContentType::Animation:

View File

@ -102,6 +102,8 @@ bool is_supported_reply_message_content(MessageContentType content_type);
bool is_expired_message_content(MessageContentType content_type);
MessageContentType get_expired_message_content_type(MessageContentType content_type);
bool can_have_message_content_caption(MessageContentType content_type);
uint64 get_message_content_chain_id(MessageContentType content_type);

View File

@ -33945,12 +33945,8 @@ bool MessagesManager::update_message_content(DialogId dialog_id, Message *old_me
bool need_finish_upload = old_file_id.is_valid() && need_merge_files;
if (old_content_type != new_content_type) {
if (old_message->ttl.is_valid() && old_message->ttl_expires_at > 0 &&
((new_content_type == MessageContentType::ExpiredPhoto && old_content_type == MessageContentType::Photo) ||
(new_content_type == MessageContentType::ExpiredVideo && old_content_type == MessageContentType::Video) ||
(new_content_type == MessageContentType::ExpiredVideoNote &&
old_content_type == MessageContentType::VideoNote) ||
(new_content_type == MessageContentType::ExpiredVoiceNote &&
old_content_type == MessageContentType::VoiceNote))) {
is_expired_message_content(new_content_type) &&
get_expired_message_content_type(old_content_type) == new_content_type) {
LOG(INFO) << "Do not apply expired message content early";
} else {
need_update = true;