Fix handling of some message contents in on_message_ttl_expired_impl.

GitOrigin-RevId: 1ad333a8f050f1d86bf769158a55f6cf113b66f3
This commit is contained in:
levlam 2018-08-04 23:46:43 +03:00
parent 2465356c2e
commit b97570b817

View File

@ -8024,7 +8024,7 @@ bool MessagesManager::can_have_message_content_caption(int32 content_type) {
string MessagesManager::get_search_text(const Message *m) { string MessagesManager::get_search_text(const Message *m) {
if (m->is_content_secret) { if (m->is_content_secret) {
return ""; return string();
} }
switch (m->content->get_id()) { switch (m->content->get_id()) {
case MessageText::ID: { case MessageText::ID: {
@ -8051,7 +8051,7 @@ string MessagesManager::get_search_text(const Message *m) {
} }
case MessagePhoto::ID: { case MessagePhoto::ID: {
auto photo = static_cast<const MessagePhoto *>(m->content.get()); auto photo = static_cast<const MessagePhoto *>(m->content.get());
return PSTRING() << photo->caption.text; return photo->caption.text;
} }
case MessageVideo::ID: { case MessageVideo::ID: {
auto video = static_cast<const MessageVideo *>(m->content.get()); auto video = static_cast<const MessageVideo *>(m->content.get());
@ -8090,10 +8090,10 @@ string MessagesManager::get_search_text(const Message *m) {
case MessageWebsiteConnected::ID: case MessageWebsiteConnected::ID:
case MessagePassportDataSent::ID: case MessagePassportDataSent::ID:
case MessagePassportDataReceived::ID: case MessagePassportDataReceived::ID:
return ""; return string();
default: default:
UNREACHABLE(); UNREACHABLE();
return ""; return string();
} }
} }
@ -9802,8 +9802,20 @@ void MessagesManager::on_message_ttl_expired_impl(Dialog *d, Message *message) {
case MessageUnsupported::ID: case MessageUnsupported::ID:
// can happen if message content file id is broken // can happen if message content file id is broken
break; break;
case MessageExpiredPhoto::ID:
case MessageExpiredVideo::ID:
// can happen if message content has been reget from somewhere
break;
case MessageAnimation::ID:
case MessageAudio::ID:
case MessageDocument::ID:
case MessageSticker::ID:
case MessageVideoNote::ID:
case MessageVoiceNote::ID:
// can happen if server will send a document with a wrong content
message->content = make_unique<MessageExpiredVideo>();
break;
default: default:
CHECK(false) << d->dialog_id << " " << message->ttl << " " << message->content->get_id();
UNREACHABLE(); UNREACHABLE();
} }
message->ttl = 0; message->ttl = 0;