Add is_supported_reply_message_content.

This commit is contained in:
levlam 2023-12-21 17:24:21 +03:00
parent 092144cf43
commit b7f5949b98
3 changed files with 41 additions and 31 deletions

View File

@ -303,6 +303,8 @@ bool is_service_message_content(MessageContentType content_type) {
case MessageContentType::Contact:
case MessageContentType::Dice:
case MessageContentType::Document:
case MessageContentType::ExpiredPhoto:
case MessageContentType::ExpiredVideo:
case MessageContentType::Game:
case MessageContentType::Giveaway:
case MessageContentType::GiveawayWinners:
@ -319,8 +321,6 @@ bool is_service_message_content(MessageContentType content_type) {
case MessageContentType::Video:
case MessageContentType::VideoNote:
case MessageContentType::VoiceNote:
case MessageContentType::ExpiredPhoto:
case MessageContentType::ExpiredVideo:
return false;
case MessageContentType::ChatCreate:
case MessageContentType::ChatChangeTitle:
@ -369,6 +369,40 @@ bool is_service_message_content(MessageContentType content_type) {
}
}
bool is_supported_reply_message_content(MessageContentType content_type) {
// update documentation when the list changes
switch (content_type) {
case MessageContentType::Animation:
case MessageContentType::Audio:
case MessageContentType::Contact:
case MessageContentType::Dice:
case MessageContentType::Document:
case MessageContentType::Game:
case MessageContentType::Giveaway:
case MessageContentType::GiveawayWinners:
case MessageContentType::Invoice:
case MessageContentType::Location:
case MessageContentType::Photo:
case MessageContentType::Poll:
case MessageContentType::Sticker:
case MessageContentType::Story:
case MessageContentType::Text:
case MessageContentType::Unsupported:
case MessageContentType::Venue:
case MessageContentType::Video:
case MessageContentType::VideoNote:
case MessageContentType::VoiceNote:
return true;
case MessageContentType::ExpiredPhoto:
case MessageContentType::ExpiredVideo:
case MessageContentType::LiveLocation:
return false;
default:
UNREACHABLE();
return false;
}
}
bool can_have_message_content_caption(MessageContentType content_type) {
switch (content_type) {
case MessageContentType::Animation:

View File

@ -90,6 +90,8 @@ bool is_secret_message_content(int32 ttl, MessageContentType content_type);
bool is_service_message_content(MessageContentType content_type);
bool is_supported_reply_message_content(MessageContentType content_type);
bool can_have_message_content_caption(MessageContentType content_type);
uint64 get_message_content_chain_id(MessageContentType content_type);

View File

@ -9,7 +9,6 @@
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/MessageContent.h"
#include "td/telegram/MessageContentType.h"
#include "td/telegram/MessageCopyOptions.h"
#include "td/telegram/MessageFullId.h"
#include "td/telegram/MessagesManager.h"
@ -108,34 +107,9 @@ RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messa
content_ = get_message_content(td, FormattedText(), std::move(reply_header->reply_media_), dialog_id,
origin_date_, true, UserId(), nullptr, nullptr, "messageReplyHeader");
CHECK(content_ != nullptr);
switch (content_->get_type()) {
case MessageContentType::Animation:
case MessageContentType::Audio:
case MessageContentType::Contact:
case MessageContentType::Dice:
case MessageContentType::Document:
// case MessageContentType::ExpiredPhoto:
// case MessageContentType::ExpiredVideo:
case MessageContentType::Game:
case MessageContentType::Giveaway:
case MessageContentType::GiveawayWinners:
case MessageContentType::Invoice:
// case MessageContentType::LiveLocation:
case MessageContentType::Location:
case MessageContentType::Photo:
case MessageContentType::Poll:
case MessageContentType::Sticker:
case MessageContentType::Story:
case MessageContentType::Text:
case MessageContentType::Unsupported:
case MessageContentType::Venue:
case MessageContentType::Video:
case MessageContentType::VideoNote:
case MessageContentType::VoiceNote:
break;
default:
LOG(ERROR) << "Receive reply with media of the type " << content_->get_type();
content_ = nullptr;
if (!is_supported_reply_message_content(content_->get_type())) {
LOG(ERROR) << "Receive reply with media of the type " << content_->get_type();
content_ = nullptr;
}
}
}