Better MessageUnsupported support.
GitOrigin-RevId: 7b2b83c83e8b602dfd371fb5c9c598b3a5c31839
This commit is contained in:
parent
480772c4cf
commit
4ec320cd0a
@ -417,10 +417,15 @@ class MessageChatSetTtl : public MessageContent {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class MessageUnsupported
|
class MessageUnsupported : public MessageContent {
|
||||||
: public MessageContent { // TODO save a layer in which the message was received to
|
|
||||||
// automatically reget it if the layer changes
|
|
||||||
public:
|
public:
|
||||||
|
static constexpr int32 CURRENT_VERSION = 1;
|
||||||
|
int32 version = CURRENT_VERSION;
|
||||||
|
|
||||||
|
MessageUnsupported() = default;
|
||||||
|
explicit MessageUnsupported(int32 version) : version(version) {
|
||||||
|
}
|
||||||
|
|
||||||
MessageContentType get_type() const override {
|
MessageContentType get_type() const override {
|
||||||
return MessageContentType::Unsupported;
|
return MessageContentType::Unsupported;
|
||||||
}
|
}
|
||||||
@ -782,8 +787,11 @@ static void store(const MessageContent *content, StorerT &storer) {
|
|||||||
store(m->web_page_id, storer);
|
store(m->web_page_id, storer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageContentType::Unsupported:
|
case MessageContentType::Unsupported: {
|
||||||
|
auto m = static_cast<const MessageUnsupported *>(content);
|
||||||
|
store(m->version, storer);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case MessageContentType::Venue: {
|
case MessageContentType::Venue: {
|
||||||
auto m = static_cast<const MessageVenue *>(content);
|
auto m = static_cast<const MessageVenue *>(content);
|
||||||
store(m->venue, storer);
|
store(m->venue, storer);
|
||||||
@ -1067,9 +1075,16 @@ static void parse(unique_ptr<MessageContent> &content, ParserT &parser) {
|
|||||||
content = std::move(m);
|
content = std::move(m);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageContentType::Unsupported:
|
case MessageContentType::Unsupported: {
|
||||||
content = make_unique<MessageUnsupported>();
|
auto m = make_unique<MessageUnsupported>();
|
||||||
|
if (parser.version() >= static_cast<int32>(Version::AddMessageUnsupportedVersion)) {
|
||||||
|
parse(m->version, parser);
|
||||||
|
} else {
|
||||||
|
m->version = 0;
|
||||||
|
}
|
||||||
|
content = std::move(m);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case MessageContentType::Venue: {
|
case MessageContentType::Venue: {
|
||||||
auto m = make_unique<MessageVenue>();
|
auto m = make_unique<MessageVenue>();
|
||||||
parse(m->venue, parser);
|
parse(m->venue, parser);
|
||||||
@ -1270,7 +1285,7 @@ static void parse(unique_ptr<MessageContent> &content, ParserT &parser) {
|
|||||||
}
|
}
|
||||||
if (is_bad) {
|
if (is_bad) {
|
||||||
LOG(ERROR) << "Load a message with an invalid content of type " << content_type;
|
LOG(ERROR) << "Load a message with an invalid content of type " << content_type;
|
||||||
content = make_unique<MessageUnsupported>();
|
content = make_unique<MessageUnsupported>(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2976,8 +2991,14 @@ void merge_message_contents(Td *td, MessageContent *old_content, MessageContent
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageContentType::Unsupported:
|
case MessageContentType::Unsupported: {
|
||||||
|
auto old_ = static_cast<const MessageUnsupported *>(old_content);
|
||||||
|
auto new_ = static_cast<const MessageUnsupported *>(new_content);
|
||||||
|
if (old_->version != new_->version) {
|
||||||
|
is_content_changed = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
@ -4119,9 +4140,8 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
|||||||
return make_tl_object<td_api::messageText>(get_formatted_text_object(m->text),
|
return make_tl_object<td_api::messageText>(get_formatted_text_object(m->text),
|
||||||
td->web_pages_manager_->get_web_page_object(m->web_page_id));
|
td->web_pages_manager_->get_web_page_object(m->web_page_id));
|
||||||
}
|
}
|
||||||
case MessageContentType::Unsupported: {
|
case MessageContentType::Unsupported:
|
||||||
return make_tl_object<td_api::messageUnsupported>();
|
return make_tl_object<td_api::messageUnsupported>();
|
||||||
}
|
|
||||||
case MessageContentType::Venue: {
|
case MessageContentType::Venue: {
|
||||||
const MessageVenue *m = static_cast<const MessageVenue *>(content);
|
const MessageVenue *m = static_cast<const MessageVenue *>(content);
|
||||||
return make_tl_object<td_api::messageVenue>(m->venue.get_venue_object());
|
return make_tl_object<td_api::messageVenue>(m->venue.get_venue_object());
|
||||||
@ -4494,6 +4514,18 @@ string get_message_content_search_text(const Td *td, const MessageContent *conte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool need_reget_message_content(const MessageContent *content) {
|
||||||
|
CHECK(content != nullptr);
|
||||||
|
switch (content->get_type()) {
|
||||||
|
case MessageContentType::Unsupported: {
|
||||||
|
auto message_unsupported = static_cast<const MessageUnsupported *>(content);
|
||||||
|
return message_unsupported->version != MessageUnsupported::CURRENT_VERSION;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void update_expired_message_content(unique_ptr<MessageContent> &content) {
|
void update_expired_message_content(unique_ptr<MessageContent> &content) {
|
||||||
switch (content->get_type()) {
|
switch (content->get_type()) {
|
||||||
case MessageContentType::Photo:
|
case MessageContentType::Photo:
|
||||||
|
@ -218,6 +218,8 @@ vector<FileId> get_message_content_file_ids(const MessageContent *content, const
|
|||||||
|
|
||||||
string get_message_content_search_text(const Td *td, const MessageContent *content);
|
string get_message_content_search_text(const Td *td, const MessageContent *content);
|
||||||
|
|
||||||
|
bool need_reget_message_content(const MessageContent *content);
|
||||||
|
|
||||||
void update_expired_message_content(unique_ptr<MessageContent> &content);
|
void update_expired_message_content(unique_ptr<MessageContent> &content);
|
||||||
|
|
||||||
void add_message_content_dependencies(Dependencies &dependencies, const MessageContent *message_content);
|
void add_message_content_dependencies(Dependencies &dependencies, const MessageContent *message_content);
|
||||||
|
@ -21188,6 +21188,13 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
|
|||||||
on_dialog_updated(dialog_id, "update_has_contact_registered_message");
|
on_dialog_updated(dialog_id, "update_has_contact_registered_message");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message_id.is_server() && dialog_id.get_type() != DialogType::SecretChat &&
|
||||||
|
need_reget_message_content(m->content.get())) {
|
||||||
|
FullMessageId full_message_id{dialog_id, message_id};
|
||||||
|
LOG(INFO) << "Reget from server " << full_message_id;
|
||||||
|
get_messages_from_server({full_message_id}, Auto());
|
||||||
|
}
|
||||||
|
|
||||||
if (from_update && message_id.is_server() && dialog_id.get_type() == DialogType::Channel) {
|
if (from_update && message_id.is_server() && dialog_id.get_type() == DialogType::Channel) {
|
||||||
int32 new_participant_count = get_message_content_new_participant_count(m->content.get());
|
int32 new_participant_count = get_message_content_new_participant_count(m->content.get());
|
||||||
if (new_participant_count != 0) {
|
if (new_participant_count != 0) {
|
||||||
|
@ -2039,7 +2039,6 @@ void NotificationManager::get_current_state(vector<td_api::object_ptr<td_api::Up
|
|||||||
void NotificationManager::flush_all_notifications() {
|
void NotificationManager::flush_all_notifications() {
|
||||||
flush_all_pending_notifications();
|
flush_all_pending_notifications();
|
||||||
flush_all_pending_updates(true, "flush_all_notifications");
|
flush_all_pending_updates(true, "flush_all_notifications");
|
||||||
CHECK(pending_notification_update_count_ == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::destroy_all_notifications() {
|
void NotificationManager::destroy_all_notifications() {
|
||||||
@ -2071,6 +2070,8 @@ void NotificationManager::on_pending_notification_update_count_changed(int32 dif
|
|||||||
bool had_pending = pending_notification_update_count_ != 0;
|
bool had_pending = pending_notification_update_count_ != 0;
|
||||||
pending_notification_update_count_ += diff;
|
pending_notification_update_count_ += diff;
|
||||||
CHECK(pending_notification_update_count_ >= 0);
|
CHECK(pending_notification_update_count_ >= 0);
|
||||||
|
VLOG(notifications) << "Update pending notification count with diff " << diff << " to "
|
||||||
|
<< pending_notification_update_count_;
|
||||||
bool have_pending = pending_notification_update_count_ != 0;
|
bool have_pending = pending_notification_update_count_ != 0;
|
||||||
if (had_pending != have_pending && !is_destroyed_) {
|
if (had_pending != have_pending && !is_destroyed_) {
|
||||||
auto update = td_api::make_object<td_api::updateHavePendingNotifications>(have_pending);
|
auto update = td_api::make_object<td_api::updateHavePendingNotifications>(have_pending);
|
||||||
|
@ -26,6 +26,7 @@ enum class Version : int32 {
|
|||||||
AddVenueType,
|
AddVenueType,
|
||||||
AddTermsOfService,
|
AddTermsOfService,
|
||||||
AddContactVcard,
|
AddContactVcard,
|
||||||
|
AddMessageUnsupportedVersion,
|
||||||
Next
|
Next
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user