Add td_api::messageForwardedFromHiddenUser.

GitOrigin-RevId: 1b3c79ad6bbfcee18d8138580ebc15bf12ad2185
This commit is contained in:
levlam 2019-03-29 04:43:01 +03:00
parent 84a513fe61
commit 8c8fd71029
4 changed files with 30 additions and 8 deletions

View File

@ -468,12 +468,21 @@ secretChat id:int32 user_id:int32 state:SecretChatState is_outbound:Bool ttl:int
//@class MessageForwardInfo @description Contains information about the initial sender of a forwarded message
//@description The message was originally written by a known user @sender_user_id Identifier of the user that originally sent this message @date Point in time (Unix timestamp) when the message was originally sent
//@description The message was originally written by a known user
//@sender_user_id Identifier of the user that originally sent this message
//@date Point in time (Unix timestamp) when the message was originally sent
//@forwarded_from_chat_id For messages forwarded to the chat with the current user (saved messages), the identifier of the chat from which the message was forwarded; 0 if unknown
//@forwarded_from_message_id For messages forwarded to the chat with the current user (saved messages) the identifier of the original message from which the new message was forwarded; 0 if unknown
messageForwardedFromUser sender_user_id:int32 date:int32 forwarded_from_chat_id:int53 forwarded_from_message_id:int53 = MessageForwardInfo;
//@description The message was originally a post in a channel @chat_id Identifier of the chat from which the message was forwarded @author_signature Post author signature
//@description The message was originally written by a user, which is hidden by his privacy settings
//@sender_name Name of the sender
//@date Point in time (Unix timestamp) when the message was originally sent
messageForwardedFromHiddenUser sender_name:string date:int32 = MessageForwardInfo;
//@description The message was originally a post in a channel
//@chat_id Identifier of the chat from which the message was forwarded
//@author_signature Post author signature
//@date Point in time (Unix timestamp) when the message was originally sent @message_id Message identifier of the original message from which the new message was forwarded; 0 if unknown
//@forwarded_from_chat_id For messages forwarded to the chat with the current user (saved messages), the identifier of the chat from which the message was forwarded; 0 if unknown
//@forwarded_from_message_id For messages forwarded to the chat with the current user (saved messages), the identifier of the original message from which the new message was forwarded; 0 if unknown

Binary file not shown.

View File

@ -17437,6 +17437,11 @@ tl_object_ptr<td_api::gameHighScores> MessagesManager::get_game_high_scores_obje
return result;
}
bool MessagesManager::is_forward_info_sender_hidden(const MessageForwardInfo *forward_info) {
return forward_info->dialog_id == DialogId(static_cast<int64>(-1001228946795ll)) &&
!forward_info->author_signature.empty() && !forward_info->message_id.is_valid();
}
unique_ptr<MessagesManager::MessageForwardInfo> MessagesManager::get_message_forward_info(
tl_object_ptr<telegram_api::messageFwdHeader> &&forward_header) {
if (forward_header == nullptr) {
@ -17524,11 +17529,15 @@ tl_object_ptr<td_api::MessageForwardInfo> MessagesManager::get_message_forward_i
}
if (forward_info->dialog_id.is_valid()) {
return make_tl_object<td_api::messageForwardedPost>(
if (is_forward_info_sender_hidden(forward_info.get())) {
return td_api::make_object<td_api::messageForwardedFromHiddenUser>(forward_info->author_signature,
forward_info->date);
}
return td_api::make_object<td_api::messageForwardedPost>(
forward_info->dialog_id.get(), forward_info->author_signature, forward_info->date,
forward_info->message_id.get(), forward_info->from_dialog_id.get(), forward_info->from_message_id.get());
}
return make_tl_object<td_api::messageForwardedFromUser>(
return td_api::make_object<td_api::messageForwardedFromUser>(
td_->contacts_manager_->get_user_id_object(forward_info->sender_user_id, "messageForwardedFromUser"),
forward_info->date, forward_info->from_dialog_id.get(), forward_info->from_message_id.get());
}
@ -22799,10 +22808,12 @@ bool MessagesManager::update_message(Dialog *d, unique_ptr<Message> &old_message
is_changed = true;
}
if (*old_message->forward_info != *new_message->forward_info) {
LOG(ERROR) << message_id << " in " << dialog_id << " has changed forward info from "
<< *old_message->forward_info << " to " << *new_message->forward_info << ", really forwarded from "
<< old_message->debug_forward_from << ", message content type is "
<< old_message->content->get_type() << '/' << new_message->content->get_type();
if (!is_forward_info_sender_hidden(new_message->forward_info.get())) {
LOG(ERROR) << message_id << " in " << dialog_id << " has changed forward info from "
<< *old_message->forward_info << " to " << *new_message->forward_info << ", really forwarded from "
<< old_message->debug_forward_from << ", message content type is "
<< old_message->content->get_type() << '/' << new_message->content->get_type();
}
old_message->forward_info = std::move(new_message->forward_info);
is_changed = true;
}

View File

@ -1854,6 +1854,8 @@ class MessagesManager : public Actor {
static int32 get_message_flags(const Message *m);
static bool is_forward_info_sender_hidden(const MessageForwardInfo *forward_info);
unique_ptr<MessageForwardInfo> get_message_forward_info(
tl_object_ptr<telegram_api::messageFwdHeader> &&forward_header);