Add author_signature to message forward origin.

GitOrigin-RevId: df1046ec0a30e2ccf43867d6dcc4558b0212c0c6
This commit is contained in:
levlam 2020-10-30 18:24:17 +03:00
parent e8d97ebbcd
commit e97d547edf
3 changed files with 14 additions and 18 deletions

View File

@ -639,8 +639,10 @@ messageSenders total_count:int32 senders:vector<MessageSender> = MessageSenders;
//@description The message was originally sent by a known user @sender_user_id Identifier of the user that originally sent the message
messageForwardOriginUser sender_user_id:int32 = MessageForwardOrigin;
//@description The message was originally sent by an anonymous chat administrator on behalf of the chat @sender_chat_id Identifier of the chat that originally sent the message
messageForwardOriginChat sender_chat_id:int53 = MessageForwardOrigin;
//@description The message was originally sent by an anonymous chat administrator on behalf of the chat
//@sender_chat_id Identifier of the chat that originally sent the message
//@author_signature Original message author signature
messageForwardOriginChat sender_chat_id:int53 author_signature:string = MessageForwardOrigin;
//@description The message was originally sent by a user, which is hidden by their privacy settings @sender_name Name of the sender
messageForwardOriginHiddenUser sender_name:string = MessageForwardOrigin;
@ -711,7 +713,7 @@ messageSendingStateFailed error_code:int32 error_message:string can_retry:Bool r
//@ttl For self-destructing messages, the message's TTL (Time To Live), in seconds; 0 if none. TDLib will send updateDeleteMessages or updateMessageContent once the TTL expires
//@ttl_expires_in Time left before the message expires, in seconds
//@via_bot_user_id If non-zero, the user identifier of the bot through which this message was sent
//@author_signature For channel posts, optional author signature
//@author_signature For channel posts and anonymous administrator messages, optional author signature
//@media_album_id Unique identifier of an album this message belongs to. Only photos and videos can be grouped together in albums
//@restriction_reason If non-empty, contains a human-readable description of the reason why access to this message must be restricted
//@content Content of the message

Binary file not shown.

View File

@ -25021,10 +25021,10 @@ unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_for
auto flags = forward_header->flags_;
DialogId sender_dialog_id;
MessageId message_id;
string author_signature;
string author_signature = std::move(forward_header->post_author_);
DialogId from_dialog_id;
MessageId from_message_id;
string sender_name;
string sender_name = std::move(forward_header->from_name_);
if (forward_header->from_id_ != nullptr) {
sender_dialog_id = DialogId(forward_header->from_id_);
if (!sender_dialog_id.is_valid()) {
@ -25032,18 +25032,13 @@ unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_for
sender_dialog_id = DialogId();
}
}
constexpr int32 MESSAGE_FORWARD_HEADER_FLAG_HAS_MESSAGE_ID = telegram_api::messageFwdHeader::CHANNEL_POST_MASK;
if ((flags & MESSAGE_FORWARD_HEADER_FLAG_HAS_MESSAGE_ID) != 0) {
if ((flags & telegram_api::messageFwdHeader::CHANNEL_POST_MASK) != 0) {
message_id = MessageId(ServerMessageId(forward_header->channel_post_));
if (!message_id.is_valid()) {
LOG(ERROR) << "Receive " << message_id << " in message forward header: " << oneline(to_string(forward_header));
message_id = MessageId();
}
}
constexpr int32 MESSAGE_FORWARD_HEADER_FLAG_HAS_AUTHOR_SIGNATURE = telegram_api::messageFwdHeader::POST_AUTHOR_MASK;
if ((flags & MESSAGE_FORWARD_HEADER_FLAG_HAS_AUTHOR_SIGNATURE) != 0) {
author_signature = std::move(forward_header->post_author_);
}
if ((flags & telegram_api::messageFwdHeader::SAVED_FROM_PEER_MASK) != 0) {
from_dialog_id = DialogId(forward_header->saved_from_peer_);
from_message_id = MessageId(ServerMessageId(forward_header->saved_from_msg_id_));
@ -25054,9 +25049,6 @@ unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_for
from_message_id = MessageId();
}
}
if ((flags & telegram_api::messageFwdHeader::FROM_NAME_MASK) != 0) {
sender_name = std::move(forward_header->from_name_);
}
UserId sender_user_id;
if (sender_dialog_id.get_type() == DialogType::User) {
@ -25109,7 +25101,9 @@ td_api::object_ptr<td_api::messageForwardInfo> MessagesManager::get_message_forw
forward_info->sender_dialog_id.get(), forward_info->message_id.get(), forward_info->author_signature);
}
if (forward_info->sender_dialog_id.is_valid()) {
return td_api::make_object<td_api::messageForwardOriginChat>(forward_info->sender_dialog_id.get());
return td_api::make_object<td_api::messageForwardOriginChat>(
forward_info->sender_dialog_id.get(),
forward_info->sender_name.empty() ? forward_info->author_signature : forward_info->sender_name);
}
return td_api::make_object<td_api::messageForwardOriginUser>(
td_->contacts_manager_->get_user_id_object(forward_info->sender_user_id, "messageForwardOriginUser"));
@ -25406,9 +25400,9 @@ Result<vector<MessageId>> MessagesManager::forward_messages(DialogId to_dialog_i
LOG(ERROR) << "Don't know how to forward a channel post not from a channel";
}
} else if (forwarded_message->sender_user_id.is_valid() || forwarded_message->sender_dialog_id.is_valid()) {
forward_info = make_unique<MessageForwardInfo>(forwarded_message->sender_user_id, forwarded_message->date,
forwarded_message->sender_dialog_id, MessageId(), "", "",
saved_from_dialog_id, saved_from_message_id, "");
forward_info = td::make_unique<MessageForwardInfo>(
forwarded_message->sender_user_id, forwarded_message->date, forwarded_message->sender_dialog_id,
MessageId(), "", forwarded_message->author_signature, saved_from_dialog_id, saved_from_message_id, "");
} else {
LOG(ERROR) << "Don't know how to forward a non-channel post message without forward info and sender";
}