diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index dfc3ef26b..b346d127b 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1181,6 +1181,12 @@ messageOriginChat sender_chat_id:int53 author_signature:string = MessageOrigin; messageOriginChannel chat_id:int53 message_id:int53 author_signature:string = MessageOrigin; +//@description Contains information about the last message from which the new message was forwarded last time +//@chat_id Identifier of the chat from which the message was forwarded last time +//@message_id Identifier of the source message from which the message was forwarded last time +forwardSource chat_id:int53 message_id:int53 = ForwardSource; + + //@class ReactionType @description Describes type of message reaction //@description A reaction with an emoji @emoji Text representation of the reaction @@ -1193,10 +1199,9 @@ reactionTypeCustomEmoji custom_emoji_id:int64 = ReactionType; //@description Contains information about a forwarded message //@origin Origin of the forwarded message //@date Point in time (Unix timestamp) when the message was originally sent +//@source For messages forwarded to the chat with the current user (Saved Messages), to the Replies bot chat, or to the channel's discussion group, information about the source message, from which the message was forwarded last time; may be null for other forwards or if unknown //@public_service_announcement_type The type of a public service announcement for the forwarded message -//@from_chat_id For messages forwarded to the chat with the current user (Saved Messages), to the Replies bot chat, or to the channel's discussion group, the identifier of the chat from which the message was forwarded last time; 0 if unknown -//@from_message_id For messages forwarded to the chat with the current user (Saved Messages), to the Replies bot chat, or to the channel's discussion group, the identifier of the original message from which the new message was forwarded last time; 0 if unknown -messageForwardInfo origin:MessageOrigin date:int32 public_service_announcement_type:string from_chat_id:int53 from_message_id:int53 = MessageForwardInfo; +messageForwardInfo origin:MessageOrigin date:int32 source:forwardSource public_service_announcement_type:string = MessageForwardInfo; //@description Contains information about a message created with importMessages //@sender_name Name of the original sender diff --git a/td/telegram/MessageForwardInfo.cpp b/td/telegram/MessageForwardInfo.cpp index 1f6edabc2..e5343559e 100644 --- a/td/telegram/MessageForwardInfo.cpp +++ b/td/telegram/MessageForwardInfo.cpp @@ -46,6 +46,14 @@ void LastForwardedMessageInfo::add_min_channel_ids(vector &channel_id } } +td_api::object_ptr LastForwardedMessageInfo::get_forward_source_object(Td *td) const { + if (is_empty()) { + return nullptr; + } + return td_api::make_object( + td->messages_manager_->get_chat_id_object(dialog_id_, "forwardSource"), message_id_.get()); +} + bool operator==(const LastForwardedMessageInfo &lhs, const LastForwardedMessageInfo &rhs) { return lhs.dialog_id_ == rhs.dialog_id_ && lhs.message_id_ == rhs.message_id_; } @@ -111,11 +119,8 @@ td_api::object_ptr MessageForwardInfo::get_message_f if (is_imported_) { return nullptr; } - auto last_message_full_id = get_last_message_full_id(); - return td_api::make_object( - origin_.get_message_origin_object(td), date_, psa_type_, - td->messages_manager_->get_chat_id_object(last_message_full_id.get_dialog_id(), "messageForwardInfo"), - last_message_full_id.get_message_id().get()); + return td_api::make_object(origin_.get_message_origin_object(td), date_, + last_message_info_.get_forward_source_object(td), 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 a1da97af2..53a1a0179 100644 --- a/td/telegram/MessageForwardInfo.h +++ b/td/telegram/MessageForwardInfo.h @@ -47,6 +47,8 @@ class LastForwardedMessageInfo { void add_min_channel_ids(vector &channel_ids) const; + td_api::object_ptr get_forward_source_object(Td *td) const; + DialogId get_dialog_id() const { return dialog_id_; }