Automatically update forward count wnen receiving a forwarded message.

GitOrigin-RevId: a33ceb0a90cea9de89ec84c6d98c39078f3b115b
This commit is contained in:
levlam 2020-08-01 05:54:39 +03:00
parent 53ca6e4f4a
commit a9fa751689
2 changed files with 21 additions and 0 deletions

View File

@ -29270,6 +29270,10 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
}
}
}
if (!td_->auth_manager_->is_bot() && from_update && m->forward_info != nullptr &&
m->forward_info->dialog_id.is_valid() && m->forward_info->message_id.is_valid()) {
update_forward_count(m->forward_info->dialog_id, m->forward_info->message_id);
}
return result_message;
}
@ -32468,6 +32472,21 @@ void MessagesManager::update_top_dialogs(DialogId dialog_id, const Message *m) {
}
}
void MessagesManager::update_forward_count(DialogId dialog_id, MessageId message_id) {
Dialog *d = get_dialog(dialog_id);
CHECK(d != nullptr);
Message *m = get_message_force(d, message_id, "update_forward_count");
if (m != nullptr && !m->message_id.is_scheduled() && m->message_id.is_server() && m->view_count > 0) {
if (m->forward_count == 0 && update_message_interaction_info(dialog_id, m, m->view_count, 1)) {
on_message_changed(d, m, true, "update_forward_count");
}
if (d->pending_viewed_message_ids.insert(m->message_id).second) {
pending_message_views_timeout_.add_timeout_in(dialog_id.get(), 0.0);
}
}
}
void MessagesManager::try_hide_distance(DialogId dialog_id, const Message *m) {
CHECK(m != nullptr);
if (!m->is_outgoing && dialog_id != get_my_dialog_id()) {

View File

@ -2705,6 +2705,8 @@ class MessagesManager : public Actor {
void update_top_dialogs(DialogId dialog_id, const Message *m);
void update_forward_count(DialogId dialog_id, MessageId message_id);
void try_hide_distance(DialogId dialog_id, const Message *m);
string get_message_search_text(const Message *m) const;