diff --git a/td/telegram/MessageForwardInfo.cpp b/td/telegram/MessageForwardInfo.cpp index f7924036c..f3b112160 100644 --- a/td/telegram/MessageForwardInfo.cpp +++ b/td/telegram/MessageForwardInfo.cpp @@ -67,11 +67,22 @@ void LastForwardedMessageInfo::add_min_channel_ids(vector &channel_id } } -td_api::object_ptr LastForwardedMessageInfo::get_forward_source_object(Td *td) const { +td_api::object_ptr LastForwardedMessageInfo::get_forward_source_object( + Td *td, bool for_saved_messages, const MessageOrigin &origin, int32 origin_date) const { if (is_empty()) { return nullptr; } td_api::object_ptr sender_id; + if (date_ == 0 && for_saved_messages) { + auto sender_dialog_id = origin.get_sender(); + if (sender_dialog_id.is_valid()) { + sender_id = get_message_sender_object_const(td, sender_dialog_id, "origin.forwardSource.sender_id"); + } + return td_api::make_object( + td->messages_manager_->get_chat_id_object(dialog_id_, "forwardSource.chat_id"), message_id_.get(), + std::move(sender_id), origin.get_sender_name(), origin_date, is_outgoing_); + } + if (sender_dialog_id_ != DialogId()) { sender_id = get_message_sender_object_const(td, sender_dialog_id_, "forwardSource.sender_id"); } @@ -159,12 +170,14 @@ unique_ptr MessageForwardInfo::copy_message_forward_info( return result; } -td_api::object_ptr MessageForwardInfo::get_message_forward_info_object(Td *td) const { +td_api::object_ptr MessageForwardInfo::get_message_forward_info_object( + Td *td, bool for_saved_messages) const { if (is_imported_) { return nullptr; } - return td_api::make_object(origin_.get_message_origin_object(td), date_, - last_message_info_.get_forward_source_object(td), psa_type_); + return td_api::make_object( + origin_.get_message_origin_object(td), date_, + last_message_info_.get_forward_source_object(td, for_saved_messages, origin_, date_), psa_type_); } td_api::object_ptr MessageForwardInfo::get_message_import_info_object() const { diff --git a/td/telegram/MessageForwardInfo.h b/td/telegram/MessageForwardInfo.h index 009549cb3..b2c211830 100644 --- a/td/telegram/MessageForwardInfo.h +++ b/td/telegram/MessageForwardInfo.h @@ -60,7 +60,9 @@ class LastForwardedMessageInfo { void add_min_channel_ids(vector &channel_ids) const; - td_api::object_ptr get_forward_source_object(Td *td) const; + td_api::object_ptr get_forward_source_object(Td *td, bool for_saved_messages, + const MessageOrigin &origin, + int32 origin_date) const; DialogId get_dialog_id() const { return dialog_id_; @@ -111,7 +113,7 @@ class MessageForwardInfo { static unique_ptr copy_message_forward_info(Td *td, const MessageForwardInfo &forward_info, LastForwardedMessageInfo &&last_message_info); - td_api::object_ptr get_message_forward_info_object(Td *td) const; + td_api::object_ptr get_message_forward_info_object(Td *td, bool for_saved_messages) const; td_api::object_ptr get_message_import_info_object() const; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 6d8b0a64e..d4a56c22d 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -22225,7 +22225,8 @@ td_api::object_ptr MessagesManager::get_dialog_event_log_messag auto sender = get_message_sender_object_const(td_, m->sender_user_id, m->sender_dialog_id, "get_dialog_event_log_message_object"); - auto forward_info = m->forward_info == nullptr ? nullptr : m->forward_info->get_message_forward_info_object(td_); + auto forward_info = + m->forward_info == nullptr ? nullptr : m->forward_info->get_message_forward_info_object(td_, false); auto import_info = m->forward_info == nullptr ? nullptr : m->forward_info->get_message_import_info_object(); auto interaction_info = get_message_interaction_info_object(dialog_id, m); auto can_be_saved = can_save_message(dialog_id, m); @@ -22301,7 +22302,9 @@ tl_object_ptr MessagesManager::get_message_object(DialogId dial m->ttl_period == 0 ? 0.0 : clamp(m->date + m->ttl_period - G()->server_time(), 1e-3, m->ttl_period - 1e-3); auto sender = get_message_sender_object_const(td_, m->sender_user_id, m->sender_dialog_id, source); auto scheduling_state = is_scheduled ? get_message_scheduling_state_object(m->date) : nullptr; - auto forward_info = m->forward_info == nullptr ? nullptr : m->forward_info->get_message_forward_info_object(td_); + auto forward_info = m->forward_info == nullptr + ? nullptr + : m->forward_info->get_message_forward_info_object(td_, dialog_id == my_dialog_id); auto import_info = m->forward_info == nullptr ? nullptr : m->forward_info->get_message_import_info_object(); auto interaction_info = is_bot ? nullptr : get_message_interaction_info_object(dialog_id, m); auto unread_reactions = get_unread_reactions_object(dialog_id, m);