diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index bf838e3ec..0aac6373a 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -5495,8 +5495,9 @@ unique_ptr get_secret_message_content( unique_ptr get_message_content(Td *td, FormattedText message, tl_object_ptr &&media_ptr, - DialogId owner_dialog_id, bool is_content_read, UserId via_bot_user_id, - int32 *ttl, bool *disable_web_page_preview, const char *source) { + DialogId owner_dialog_id, int32 message_date, bool is_content_read, + UserId via_bot_user_id, int32 *ttl, bool *disable_web_page_preview, + const char *source) { if (!td->auth_manager_->was_authorized() && !G()->close_flag() && media_ptr != nullptr && media_ptr->get_id() != telegram_api::messageMediaEmpty::ID) { LOG(ERROR) << "Receive without authorization from " << source << ": " << to_string(media_ptr); @@ -5687,7 +5688,9 @@ unique_ptr get_message_content(Td *td, FormattedText message, } } if (channel_ids.empty() || media->quantity_ <= 0 || media->months_ <= 0 || media->until_date_ < 0) { - LOG(ERROR) << "Receive " << to_string(media); + if (message_date >= 1700000000) { // approximate release date + LOG(ERROR) << "Receive " << to_string(media); + } break; } auto boosted_channel_id = channel_ids[0]; @@ -5988,7 +5991,7 @@ unique_ptr dup_message_content(Td *td, DialogId dialog_id, const } unique_ptr get_action_message_content(Td *td, tl_object_ptr &&action_ptr, - DialogId owner_dialog_id, + DialogId owner_dialog_id, int32 message_date, const RepliedMessageInfo &replied_message_info) { CHECK(action_ptr != nullptr); @@ -6356,7 +6359,9 @@ unique_ptr get_action_message_content(Td *td, tl_object_ptr(action_ptr); auto reply_to_message_id = replied_message_info.get_same_chat_reply_to_message_id(true); if (!reply_to_message_id.is_valid()) { - LOG(ERROR) << "Receive giveaway results message with " << reply_to_message_id << " in " << owner_dialog_id; + if (message_date >= 1700000000) { // approximate release date + LOG(ERROR) << "Receive giveaway results message with " << reply_to_message_id << " in " << owner_dialog_id; + } reply_to_message_id = MessageId(); } return td::make_unique(reply_to_message_id, action->winners_count_, diff --git a/td/telegram/MessageContent.h b/td/telegram/MessageContent.h index 5b568bb74..41b68d393 100644 --- a/td/telegram/MessageContent.h +++ b/td/telegram/MessageContent.h @@ -218,8 +218,9 @@ unique_ptr get_secret_message_content( unique_ptr get_message_content(Td *td, FormattedText message_text, tl_object_ptr &&media_ptr, - DialogId owner_dialog_id, bool is_content_read, UserId via_bot_user_id, - int32 *ttl, bool *disable_web_page_preview, const char *source); + DialogId owner_dialog_id, int32 message_date, bool is_content_read, + UserId via_bot_user_id, int32 *ttl, bool *disable_web_page_preview, + const char *source); enum class MessageContentDupType : int32 { Send, // normal message sending @@ -233,7 +234,7 @@ unique_ptr dup_message_content(Td *td, DialogId dialog_id, const MessageContentDupType type, MessageCopyOptions &©_options); unique_ptr get_action_message_content(Td *td, tl_object_ptr &&action_ptr, - DialogId owner_dialog_id, + DialogId owner_dialog_id, int32 message_date, const RepliedMessageInfo &replied_message_info); tl_object_ptr get_message_content_object(const MessageContent *content, Td *td, diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 07913e255..19c5e9302 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -6655,8 +6655,8 @@ void MessagesManager::on_update_service_notification(tl_object_ptrdialog_id : DialogId(); int32 ttl = 0; bool disable_web_page_preview = false; - auto content = get_message_content(td_, std::move(message_text), std::move(update->media_), owner_dialog_id, false, - UserId(), &ttl, &disable_web_page_preview, "updateServiceNotification"); + auto content = get_message_content(td_, std::move(message_text), std::move(update->media_), owner_dialog_id, date, + false, UserId(), &ttl, &disable_web_page_preview, "updateServiceNotification"); bool is_content_secret = is_secret_message_content(ttl, content->get_type()); if (update->popup_) { @@ -14429,8 +14429,8 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message( true, td_->auth_manager_->is_bot(), message_info.forward_header ? message_info.forward_header->date_ : message_info.date, message_info.media_album_id != 0, new_source.c_str()), - std::move(message->media_), message_info.dialog_id, is_content_read, message_info.via_bot_user_id, - &message_info.ttl, &message_info.disable_web_page_preview, new_source.c_str()); + std::move(message->media_), message_info.dialog_id, message_info.date, is_content_read, + message_info.via_bot_user_id, &message_info.ttl, &message_info.disable_web_page_preview, new_source.c_str()); message_info.reply_markup = std::move(message->reply_markup_); message_info.restriction_reasons = get_restriction_reasons(std::move(message->restriction_reason_)); message_info.author_signature = std::move(message->post_author_); @@ -14457,8 +14457,9 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message( message_info.dialog_id.get_type() == DialogType::Channel && !is_broadcast_channel(message_info.dialog_id); message_info.reply_header = MessageReplyHeader(td_, std::move(message->reply_to_), message_info.dialog_id, message_info.message_id, message_info.date, can_have_thread); - message_info.content = get_action_message_content(td_, std::move(message->action_), message_info.dialog_id, - message_info.reply_header.replied_message_info_); + message_info.content = + get_action_message_content(td_, std::move(message->action_), message_info.dialog_id, message_info.date, + message_info.reply_header.replied_message_info_); message_info.reply_header.replied_message_info_ = RepliedMessageInfo(); message_info.reply_header.story_full_id_ = StoryFullId(); break; @@ -15523,7 +15524,7 @@ void MessagesManager::on_update_sent_text_message(int64 random_id, FormattedText new_message_text = get_message_text( td_->contacts_manager_.get(), old_message_text->text, std::move(entities), true, td_->auth_manager_->is_bot(), m->forward_info ? m->forward_info->date : m->date, m->media_album_id != 0, "on_update_sent_text_message"); - auto new_content = get_message_content(td_, std::move(new_message_text), std::move(message_media), dialog_id, + auto new_content = get_message_content(td_, std::move(new_message_text), std::move(message_media), dialog_id, m->date, true /*likely ignored*/, UserId() /*likely ignored*/, nullptr /*ignored*/, nullptr, "on_update_sent_text_message"); if (new_content->get_type() != MessageContentType::Text) { @@ -25729,7 +25730,7 @@ 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"); + m->date, false, UserId(), nullptr, nullptr, "on_upload_message_media_success"); set_message_content_has_spoiler(content.get(), has_spoiler); bool is_content_changed = false; diff --git a/td/telegram/RepliedMessageInfo.cpp b/td/telegram/RepliedMessageInfo.cpp index 2d0e39b53..01db210d4 100644 --- a/td/telegram/RepliedMessageInfo.cpp +++ b/td/telegram/RepliedMessageInfo.cpp @@ -105,8 +105,8 @@ RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptrreply_media_ != nullptr && reply_header->reply_media_->get_id() != telegram_api::messageMediaEmpty::ID) { - content_ = get_message_content(td, FormattedText(), std::move(reply_header->reply_media_), dialog_id, true, - UserId(), nullptr, nullptr, "messageReplyHeader"); + 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: diff --git a/td/telegram/SponsoredMessageManager.cpp b/td/telegram/SponsoredMessageManager.cpp index ad4a44991..46bbe7464 100644 --- a/td/telegram/SponsoredMessageManager.cpp +++ b/td/telegram/SponsoredMessageManager.cpp @@ -430,8 +430,9 @@ void SponsoredMessageManager::on_get_dialog_sponsored_messages( "on_get_dialog_sponsored_messages"); int32 ttl = 0; bool disable_web_page_preview = false; - auto content = get_message_content(td_, std::move(message_text), nullptr, sponsor_dialog_id, true, UserId(), - &ttl, &disable_web_page_preview, "on_get_dialog_sponsored_messages"); + auto content = + get_message_content(td_, std::move(message_text), nullptr, sponsor_dialog_id, G()->unix_time(), true, + UserId(), &ttl, &disable_web_page_preview, "on_get_dialog_sponsored_messages"); if (ttl != 0) { LOG(ERROR) << "Receive sponsored message with self-destruct time " << ttl; continue;