Support for unknown forward headers.

GitOrigin-RevId: 4073ce4d467e0e1bec90dcb6e4c7ec503e069e9d
This commit is contained in:
levlam 2019-03-14 22:00:31 +03:00
parent a5c18d5f12
commit 8bc3ff622f
2 changed files with 22 additions and 8 deletions

View File

@ -3544,6 +3544,7 @@ void MessagesManager::Message::store(StorerT &storer) const {
BEGIN_STORE_FLAGS(); BEGIN_STORE_FLAGS();
STORE_FLAG(has_notification_id); STORE_FLAG(has_notification_id);
STORE_FLAG(is_mention_notification_disabled); STORE_FLAG(is_mention_notification_disabled);
STORE_FLAG(had_forward_info);
END_STORE_FLAGS(); END_STORE_FLAGS();
} }
@ -3669,6 +3670,7 @@ void MessagesManager::Message::parse(ParserT &parser) {
BEGIN_PARSE_FLAGS(); BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_notification_id); PARSE_FLAG(has_notification_id);
PARSE_FLAG(is_mention_notification_disabled); PARSE_FLAG(is_mention_notification_disabled);
PARSE_FLAG(had_forward_info);
END_PARSE_FLAGS(); END_PARSE_FLAGS();
} }
@ -5391,7 +5393,7 @@ void MessagesManager::on_user_dialog_action(DialogId dialog_id, UserId user_id,
void MessagesManager::cancel_user_dialog_action(DialogId dialog_id, const Message *m) { void MessagesManager::cancel_user_dialog_action(DialogId dialog_id, const Message *m) {
CHECK(m != nullptr); CHECK(m != nullptr);
if (m->forward_info != nullptr || m->via_bot_user_id.is_valid() || m->is_channel_post) { if (m->forward_info != nullptr || m->had_forward_info || m->via_bot_user_id.is_valid() || m->is_channel_post) {
return; return;
} }
@ -5646,7 +5648,7 @@ void MessagesManager::on_message_edited(FullMessageId full_message_id) {
if (td_->auth_manager_->is_bot()) { if (td_->auth_manager_->is_bot()) {
send_update_message_edited(dialog_id, m); send_update_message_edited(dialog_id, m);
} else { } else {
if (m->forward_info == nullptr && (m->is_outgoing || dialog_id == get_my_dialog_id())) { if (m->forward_info == nullptr && !m->had_forward_info && (m->is_outgoing || dialog_id == get_my_dialog_id())) {
update_used_hashtags(dialog_id, m); update_used_hashtags(dialog_id, m);
} }
} }
@ -9773,6 +9775,8 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
views = 0; views = 0;
} }
bool has_forward_info = message_info.forward_header != nullptr;
LOG(INFO) << "Receive " << message_id << " in " << dialog_id << " from " << sender_user_id; LOG(INFO) << "Receive " << message_id << " in " << dialog_id << " from " << sender_user_id;
auto message = make_unique<Message>(); auto message = make_unique<Message>();
@ -9824,6 +9828,10 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
} }
} }
if (message->forward_info == nullptr && has_forward_info) {
message->had_forward_info = true;
}
return {dialog_id, std::move(message)}; return {dialog_id, std::move(message)};
} }
@ -16424,7 +16432,7 @@ bool MessagesManager::can_edit_message(DialogId dialog_id, const Message *m, boo
if (m->message_id.is_local()) { if (m->message_id.is_local()) {
return false; return false;
} }
if (m->forward_info != nullptr) { if (m->forward_info != nullptr || m->had_forward_info) {
return false; return false;
} }
@ -20467,7 +20475,7 @@ void MessagesManager::on_send_dialog_action_timeout(DialogId dialog_id) {
if (m == nullptr) { if (m == nullptr) {
return; return;
} }
if (m->forward_info != nullptr) { if (m->forward_info != nullptr || m->had_forward_info) {
return; return;
} }
@ -22150,7 +22158,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
auto pinned_message_id = get_message_content_pinned_message_id(m->content.get()); auto pinned_message_id = get_message_content_pinned_message_id(m->content.get());
on_update_dialog_pinned_message_id(dialog_id, pinned_message_id); on_update_dialog_pinned_message_id(dialog_id, pinned_message_id);
} }
if (!td_->auth_manager_->is_bot() && from_update && m->forward_info == nullptr && if (!td_->auth_manager_->is_bot() && from_update && m->forward_info == nullptr && !m->had_forward_info &&
(m->is_outgoing || dialog_id == my_dialog_id)) { (m->is_outgoing || dialog_id == my_dialog_id)) {
if (dialog_id.get_type() != DialogType::SecretChat && !message_id.is_local()) { if (dialog_id.get_type() != DialogType::SecretChat && !message_id.is_local()) {
on_sent_message_content(td_, m->content.get()); on_sent_message_content(td_, m->content.get());
@ -22159,7 +22167,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
} }
if (!td_->auth_manager_->is_bot() && from_update && message_id.is_server() && if (!td_->auth_manager_->is_bot() && from_update && message_id.is_server() &&
(m->is_outgoing || dialog_id == my_dialog_id) && dialog_id.get_type() != DialogType::SecretChat) { (m->is_outgoing || dialog_id == my_dialog_id) && dialog_id.get_type() != DialogType::SecretChat) {
if (m->via_bot_user_id.is_valid() && m->forward_info == nullptr) { if (m->via_bot_user_id.is_valid() && m->forward_info == nullptr && !m->had_forward_info) {
// forwarded game messages can't be distinguished from sent via bot game messages, so increase rating anyway // forwarded game messages can't be distinguished from sent via bot game messages, so increase rating anyway
send_closure(G()->top_dialog_manager(), &TopDialogManager::on_dialog_used, TopDialogCategory::BotInline, send_closure(G()->top_dialog_manager(), &TopDialogManager::on_dialog_used, TopDialogCategory::BotInline,
DialogId(m->via_bot_user_id), m->date); DialogId(m->via_bot_user_id), m->date);
@ -22612,6 +22620,10 @@ bool MessagesManager::update_message(Dialog *d, unique_ptr<Message> &old_message
is_changed = true; is_changed = true;
} }
} }
if (old_message->had_forward_info != new_message->had_forward_info) {
old_message->had_forward_info = new_message->had_forward_info;
is_changed = true;
}
if (old_message->notification_id != new_message->notification_id) { if (old_message->notification_id != new_message->notification_id) {
if (old_message->notification_id.is_valid()) { if (old_message->notification_id.is_valid()) {
if (new_message->notification_id.is_valid()) { if (new_message->notification_id.is_valid()) {
@ -22771,7 +22783,8 @@ bool MessagesManager::need_message_changed_warning(const Message *old_message) {
// message was edited // message was edited
return false; return false;
} }
if (old_message->message_id.is_yet_unsent() && old_message->forward_info != nullptr) { if (old_message->message_id.is_yet_unsent() &&
(old_message->forward_info != nullptr || old_message->had_forward_info)) {
// original message may be edited // original message may be edited
return false; return false;
} }

View File

@ -834,7 +834,8 @@ class MessagesManager : public Actor {
bool disable_notification = false; bool disable_notification = false;
bool contains_mention = false; bool contains_mention = false;
bool contains_unread_mention = false; bool contains_unread_mention = false;
bool had_reply_markup = false; // had non-inline reply markup? bool had_reply_markup = false; // had non-inline reply markup?
bool had_forward_info = false;
bool is_content_secret = false; // should be shown only while tapped bool is_content_secret = false; // should be shown only while tapped
bool is_mention_notification_disabled = false; bool is_mention_notification_disabled = false;