From 114c92f3658f8673c7174b42c411584e0e84f96a Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 6 Jun 2023 15:56:09 +0300 Subject: [PATCH] Store replied story sender as DialogId. --- td/telegram/MessageReplyHeader.cpp | 2 +- td/telegram/MessageReplyHeader.h | 2 +- td/telegram/MessagesManager.cpp | 39 +++++++++++++++++------------- td/telegram/MessagesManager.h | 2 +- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/td/telegram/MessageReplyHeader.cpp b/td/telegram/MessageReplyHeader.cpp index 810fde727..64b7e0545 100644 --- a/td/telegram/MessageReplyHeader.cpp +++ b/td/telegram/MessageReplyHeader.cpp @@ -26,7 +26,7 @@ MessageReplyHeader::MessageReplyHeader(tl_object_ptr> MessagesManager::creat fix_server_reply_to_message_id(dialog_id, message_id, reply_in_dialog_id, reply_to_message_id); fix_server_reply_to_message_id(dialog_id, message_id, reply_in_dialog_id, top_thread_message_id); - UserId reply_to_story_sender_user_id = message_info.reply_header.story_sender_user_id_; - StoryId reply_to_story_id = message_info.reply_header.story_id_; - if (reply_to_story_sender_user_id != UserId() && + auto reply_to_story_sender_dialog_id = message_info.reply_header.story_sender_dialog_id_; + auto reply_to_story_id = message_info.reply_header.story_id_; + if (reply_to_story_sender_dialog_id != DialogId() && (dialog_type != DialogType::User || - (reply_to_story_sender_user_id != my_id && reply_to_story_sender_user_id != dialog_id.get_user_id()))) { - LOG(ERROR) << "Receive reply to " << reply_to_story_id << " by " << reply_to_story_sender_user_id << " in " + (reply_to_story_sender_dialog_id != my_dialog_id && reply_to_story_sender_dialog_id != dialog_id))) { + LOG(ERROR) << "Receive reply to " << reply_to_story_id << " by " << reply_to_story_sender_dialog_id << " in " << dialog_id; - reply_to_story_sender_user_id = UserId(); + reply_to_story_sender_dialog_id = DialogId(); reply_to_story_id = StoryId(); } @@ -14637,7 +14637,7 @@ std::pair> MessagesManager::creat message->reply_in_dialog_id = reply_in_dialog_id; message->top_thread_message_id = top_thread_message_id; message->is_topic_message = is_topic_message; - message->reply_to_story_sender_user_id = reply_to_story_sender_user_id; + message->reply_to_story_sender_dialog_id = reply_to_story_sender_dialog_id; message->reply_to_story_id = reply_to_story_id; message->restriction_reasons = std::move(message_info.restriction_reasons); message->author_signature = std::move(message_info.author_signature); @@ -24181,6 +24181,13 @@ tl_object_ptr MessagesManager::get_message_object(DialogId dial auto reply_to_message_id = m->reply_to_message_id.get(); auto reply_in_dialog_id = reply_to_message_id == 0 ? DialogId() : (m->reply_in_dialog_id.is_valid() ? m->reply_in_dialog_id : dialog_id); + auto reply_to_story_id = m->reply_to_story_id.get(); + int64 reply_to_story_sender_dialog_id = 0; + if (reply_to_story_id != 0) { + CHECK(m->reply_to_story_sender_dialog_id.get_type() == DialogType::User); + reply_to_story_sender_dialog_id = td_->contacts_manager_->get_user_id_object( + m->reply_to_story_sender_dialog_id.get_user_id(), "reply_to_story_sender_dialog_id"); + } auto top_thread_message_id = m->top_thread_message_id.get(); auto date = is_scheduled ? 0 : m->date; auto edit_date = m->hide_edit_date ? 0 : m->edit_date; @@ -24207,10 +24214,9 @@ tl_object_ptr MessagesManager::get_message_object(DialogId dial has_timestamped_media, m->is_channel_post, m->is_topic_message, m->contains_unread_mention, date, edit_date, std::move(forward_info), std::move(interaction_info), std::move(unread_reactions), get_chat_id_object(reply_in_dialog_id, "get_message_object reply"), reply_to_message_id, - td_->contacts_manager_->get_user_id_object(m->reply_to_story_sender_user_id, "reply_to_story_sender_user_id"), - m->reply_to_story_id.get(), top_thread_message_id, m->ttl, ttl_expires_in, auto_delete_in, via_bot_user_id, - m->author_signature, m->media_album_id, get_restriction_reason_description(m->restriction_reasons), - std::move(content), std::move(reply_markup)); + reply_to_story_sender_dialog_id, reply_to_story_id, top_thread_message_id, m->ttl, ttl_expires_in, auto_delete_in, + via_bot_user_id, m->author_signature, m->media_album_id, + get_restriction_reason_description(m->restriction_reasons), std::move(content), std::move(reply_markup)); } tl_object_ptr MessagesManager::get_messages_object(int32 total_count, DialogId dialog_id, @@ -25388,8 +25394,7 @@ void MessagesManager::on_message_media_uploaded(DialogId dialog_id, const Messag CHECK(input_media != nullptr); const FormattedText *caption = get_message_content_caption(m->content.get()); - LOG(INFO) << "Send media from " << m->message_id << " in " << dialog_id << " in reply to " - << m->reply_to_message_id; + LOG(INFO) << "Send media from " << m->message_id << " in " << dialog_id; int64 random_id = begin_send_message(dialog_id, m); td_->create_handler()->send( file_id, thumbnail_file_id, get_message_flags(m), dialog_id, get_send_message_as_input_peer(m), diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index ba8def9ab..14c5b2454 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -1185,7 +1185,7 @@ class MessagesManager final : public Actor { int64 reply_to_random_id = 0; // for send_message DialogId reply_in_dialog_id; MessageId top_thread_message_id; - UserId reply_to_story_sender_user_id; + DialogId reply_to_story_sender_dialog_id; StoryId reply_to_story_id; MessageId linked_top_thread_message_id; vector local_thread_message_ids;