From 8c8fd71029f0d6f2f366e817467df82198306f16 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 29 Mar 2019 04:43:01 +0300 Subject: [PATCH] Add td_api::messageForwardedFromHiddenUser. GitOrigin-RevId: 1b3c79ad6bbfcee18d8138580ebc15bf12ad2185 --- td/generate/scheme/td_api.tl | 13 +++++++++++-- td/generate/scheme/td_api.tlo | Bin 146536 -> 146676 bytes td/telegram/MessagesManager.cpp | 23 +++++++++++++++++------ td/telegram/MessagesManager.h | 2 ++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 38c7ccdf..a6c2b44c 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -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 diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 1a4db964f64f894fcda9b27a52aaf6817081c9a8..91119422d564c55856449d5b284b5e80f4a6095c 100644 GIT binary patch delta 209 zcmaFygX7Cjjtv)tBv;!^wh;17EiO(>Pj$;LDo-p*@ytuhXJDTEkx_h;@D*Xk1)Hy` z#V=Ags#5C! delta 113 zcmezJljFq?jtv)t#Ake3aZ1QHwYWGjJ=HD0s64SK#WOE0fAV`q$xXsngc;{=zN!|# zoD-ys0R$#1<{57;IHw`X0uq`$=kXp0 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(-1001228946795ll)) && + !forward_info->author_signature.empty() && !forward_info->message_id.is_valid(); +} + unique_ptr MessagesManager::get_message_forward_info( tl_object_ptr &&forward_header) { if (forward_header == nullptr) { @@ -17524,11 +17529,15 @@ tl_object_ptr MessagesManager::get_message_forward_i } if (forward_info->dialog_id.is_valid()) { - return make_tl_object( + if (is_forward_info_sender_hidden(forward_info.get())) { + return td_api::make_object(forward_info->author_signature, + forward_info->date); + } + return td_api::make_object( 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( + return td_api::make_object( 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 &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; } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index cb76e32a..fedb1356 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -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 get_message_forward_info( tl_object_ptr &&forward_header);