Add source to get_message_content.
This commit is contained in:
parent
2e687480c0
commit
a67155a145
@ -4323,10 +4323,10 @@ unique_ptr<MessageContent> get_secret_message_content(
|
||||
unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
||||
tl_object_ptr<telegram_api::MessageMedia> &&media_ptr,
|
||||
DialogId owner_dialog_id, bool is_content_read, UserId via_bot_user_id,
|
||||
int32 *ttl, bool *disable_web_page_preview) {
|
||||
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 " << to_string(media_ptr);
|
||||
LOG(ERROR) << "Receive without authorization from " << source << ": " << to_string(media_ptr);
|
||||
media_ptr = nullptr;
|
||||
}
|
||||
if (disable_web_page_preview != nullptr) {
|
||||
@ -4337,7 +4337,7 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
||||
switch (constructor_id) {
|
||||
case telegram_api::messageMediaEmpty::ID:
|
||||
if (message.text.empty()) {
|
||||
LOG(ERROR) << "Receive empty message text and media for message from " << owner_dialog_id;
|
||||
LOG(ERROR) << "Receive empty message text and media from " << source;
|
||||
}
|
||||
if (disable_web_page_preview != nullptr) {
|
||||
*disable_web_page_preview = true;
|
||||
@ -4347,7 +4347,8 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
||||
auto media = move_tl_object_as<telegram_api::messageMediaPhoto>(media_ptr);
|
||||
if (media->photo_ == nullptr) {
|
||||
if ((media->flags_ & telegram_api::messageMediaPhoto::TTL_SECONDS_MASK) == 0) {
|
||||
LOG(ERROR) << "Receive messageMediaPhoto without photo and TTL: " << oneline(to_string(media));
|
||||
LOG(ERROR) << "Receive messageMediaPhoto without photo and TTL from " << source << ": "
|
||||
<< oneline(to_string(media));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -4393,7 +4394,7 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
||||
|
||||
int32 period = media->period_;
|
||||
if (period <= 0) {
|
||||
LOG(ERROR) << "Receive wrong live location period = " << period;
|
||||
LOG(ERROR) << "Receive wrong live location period = " << period << " from " << source;
|
||||
return make_unique<MessageLocation>(std::move(location));
|
||||
}
|
||||
return make_unique<MessageLiveLocation>(std::move(location), period, media->heading_,
|
||||
@ -4424,7 +4425,8 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
||||
auto media = move_tl_object_as<telegram_api::messageMediaDocument>(media_ptr);
|
||||
if (media->document_ == nullptr) {
|
||||
if ((media->flags_ & telegram_api::messageMediaDocument::TTL_SECONDS_MASK) == 0) {
|
||||
LOG(ERROR) << "Receive messageMediaDocument without document and TTL: " << oneline(to_string(media));
|
||||
LOG(ERROR) << "Receive messageMediaDocument without document and TTL from " << source << ": "
|
||||
<< oneline(to_string(media));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -4466,8 +4468,8 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
||||
}
|
||||
case telegram_api::messageMediaPoll::ID: {
|
||||
auto media = move_tl_object_as<telegram_api::messageMediaPoll>(media_ptr);
|
||||
auto poll_id = td->poll_manager_->on_get_poll(PollId(), std::move(media->poll_), std::move(media->results_),
|
||||
"messageMediaPoll");
|
||||
auto poll_id =
|
||||
td->poll_manager_->on_get_poll(PollId(), std::move(media->poll_), std::move(media->results_), source);
|
||||
if (!poll_id.is_valid()) {
|
||||
break;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ unique_ptr<MessageContent> get_secret_message_content(
|
||||
unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message_text,
|
||||
tl_object_ptr<telegram_api::MessageMedia> &&media_ptr,
|
||||
DialogId owner_dialog_id, bool is_content_read, UserId via_bot_user_id,
|
||||
int32 *ttl, bool *disable_web_page_preview);
|
||||
int32 *ttl, bool *disable_web_page_preview, const char *source);
|
||||
|
||||
enum class MessageContentDupType : int32 { Send, SendViaBot, Forward, Copy, ServerCopy };
|
||||
|
||||
|
@ -6502,7 +6502,7 @@ void MessagesManager::on_update_service_notification(tl_object_ptr<telegram_api:
|
||||
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);
|
||||
UserId(), &ttl, &disable_web_page_preview, "updateServiceNotification");
|
||||
bool is_content_secret = is_secret_message_content(ttl, content->get_type());
|
||||
|
||||
if (update->popup_) {
|
||||
@ -14205,7 +14205,7 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message(
|
||||
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);
|
||||
&message_info.ttl, &message_info.disable_web_page_preview, new_source.c_str());
|
||||
message_info.reply_markup =
|
||||
message->flags_ & MESSAGE_FLAG_HAS_REPLY_MARKUP ? std::move(message->reply_markup_) : nullptr;
|
||||
message_info.restriction_reasons = get_restriction_reasons(std::move(message->restriction_reason_));
|
||||
@ -15295,9 +15295,9 @@ 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,
|
||||
true /*likely ignored*/, UserId() /*likely ignored*/, nullptr /*ignored*/, nullptr);
|
||||
auto new_content = get_message_content(td_, std::move(new_message_text), std::move(message_media), dialog_id,
|
||||
true /*likely ignored*/, UserId() /*likely ignored*/, nullptr /*ignored*/,
|
||||
nullptr, "on_update_sent_text_message");
|
||||
if (new_content->get_type() != MessageContentType::Text) {
|
||||
LOG(ERROR) << "Text message content has changed to " << new_content->get_type();
|
||||
return;
|
||||
@ -25997,7 +25997,7 @@ void MessagesManager::on_upload_message_media_success(DialogId dialog_id, Messag
|
||||
|
||||
auto caption = get_message_content_caption(m->content.get());
|
||||
auto content = get_message_content(td_, caption == nullptr ? FormattedText() : *caption, std::move(media), dialog_id,
|
||||
false, UserId(), nullptr, nullptr);
|
||||
false, UserId(), nullptr, nullptr, "on_upload_message_media_success");
|
||||
|
||||
if (update_message_content(dialog_id, m, std::move(content), true, true, true) &&
|
||||
m->message_id == d->last_message_id) {
|
||||
|
@ -297,7 +297,7 @@ void SponsoredMessageManager::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);
|
||||
&disable_web_page_preview, "on_get_dialog_sponsored_messages");
|
||||
if (ttl != 0) {
|
||||
LOG(ERROR) << "Receive sponsored message with TTL " << ttl;
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user