Use correct update date for typings; ignore too old typings.
GitOrigin-RevId: a1dc65a74bfbc8519591b0ca6739cf04ad58b2bc
This commit is contained in:
parent
3e0fb81e09
commit
0c89d34007
@ -3460,7 +3460,7 @@ int32 ContactsManager::get_user_was_online(const User *u, UserId user_id) const
|
||||
was_online = my_was_online_local_;
|
||||
}
|
||||
} else {
|
||||
if (u->local_was_online != 0 && u->local_was_online > was_online) {
|
||||
if (u->local_was_online > 0 && u->local_was_online > was_online && u->local_was_online > G()->unix_time_cached()) {
|
||||
was_online = u->local_was_online;
|
||||
}
|
||||
}
|
||||
@ -7058,7 +7058,8 @@ void ContactsManager::on_update_user_local_was_online(User *u, UserId user_id, i
|
||||
// bring users with inaccessible status online for 5 minutes
|
||||
local_was_online += 5 * 60;
|
||||
}
|
||||
if (local_was_online < G()->unix_time_cached() + 2 || local_was_online <= u->local_was_online) {
|
||||
if (local_was_online < G()->unix_time_cached() + 2 || local_was_online <= u->local_was_online ||
|
||||
local_was_online <= u->was_online) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5347,6 +5347,10 @@ void MessagesManager::on_user_dialog_action(DialogId dialog_id, UserId user_id,
|
||||
action = make_tl_object<td_api::chatActionCancel>();
|
||||
}
|
||||
} else {
|
||||
if (date < G()->unix_time_cached() - DIALOG_ACTION_TIMEOUT - 60) {
|
||||
LOG(DEBUG) << "Ignore too old action of " << user_id << " in " << dialog_id << " sent at " << date;
|
||||
return;
|
||||
}
|
||||
auto &active_actions = active_dialog_actions_[dialog_id];
|
||||
auto it = std::find_if(active_actions.begin(), active_actions.end(),
|
||||
[user_id](const ActiveDialogAction &action) { return action.user_id == user_id; });
|
||||
|
@ -4329,11 +4329,11 @@ void Td::send_update(tl_object_ptr<td_api::Update> &&object) {
|
||||
case td_api::updateTrendingStickerSets::ID:
|
||||
VLOG(td_requests) << "Sending update: updateTrendingStickerSets { ... }";
|
||||
break;
|
||||
case td_api::updateChatReadInbox::ID * 2:
|
||||
case td_api::updateUnreadMessageCount::ID * 2:
|
||||
case td_api::updateUnreadChatCount::ID * 2:
|
||||
case td_api::updateChatOnlineMemberCount::ID * 2:
|
||||
case td_api::updateUserChatAction::ID * 2:
|
||||
case td_api::updateChatReadInbox::ID / 2:
|
||||
case td_api::updateUnreadMessageCount::ID / 2:
|
||||
case td_api::updateUnreadChatCount::ID / 2:
|
||||
case td_api::updateChatOnlineMemberCount::ID / 2:
|
||||
case td_api::updateUserChatAction::ID / 2:
|
||||
LOG(ERROR) << "Sending update: " << oneline(to_string(object));
|
||||
break;
|
||||
default:
|
||||
|
@ -705,10 +705,11 @@ void UpdatesManager::on_get_updates(tl_object_ptr<telegram_api::Updates> &&updat
|
||||
LOG(ERROR) << "Receive unacceptable short update: " << td::oneline(to_string(update));
|
||||
return get_difference("unacceptable short update");
|
||||
}
|
||||
|
||||
short_update_date_ = update->date_;
|
||||
if (!downcast_call(*update->update_, OnUpdate(this, update->update_, false))) {
|
||||
LOG(ERROR) << "Can't call on some update";
|
||||
}
|
||||
short_update_date_ = 0;
|
||||
break;
|
||||
}
|
||||
case telegram_api::updatesCombined::ID: {
|
||||
@ -1566,6 +1567,14 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChannelWebPage>
|
||||
update->pts_count_, "on_updateChannelWebPage");
|
||||
}
|
||||
|
||||
int32 UpdatesManager::get_short_update_date() const {
|
||||
int32 now = G()->unix_time();
|
||||
if (short_update_date_ > 0) {
|
||||
return min(short_update_date_, now);
|
||||
}
|
||||
return now;
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::ChatAction> UpdatesManager::convert_send_message_action(
|
||||
tl_object_ptr<telegram_api::SendMessageAction> action) {
|
||||
auto fix_progress = [](int32 progress) { return progress <= 0 || progress > 100 ? 0 : progress; };
|
||||
@ -1624,9 +1633,8 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserTyping> upd
|
||||
LOG(DEBUG) << "Ignore user typing in unknown " << dialog_id;
|
||||
return;
|
||||
}
|
||||
// TODO date
|
||||
td_->messages_manager_->on_user_dialog_action(
|
||||
dialog_id, user_id, convert_send_message_action(std::move(update->action_)), G()->unix_time_cached());
|
||||
dialog_id, user_id, convert_send_message_action(std::move(update->action_)), get_short_update_date());
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChatUserTyping> update, bool /*force_apply*/) {
|
||||
@ -1646,7 +1654,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChatUserTyping>
|
||||
}
|
||||
}
|
||||
td_->messages_manager_->on_user_dialog_action(
|
||||
dialog_id, user_id, convert_send_message_action(std::move(update->action_)), G()->unix_time_cached());
|
||||
dialog_id, user_id, convert_send_message_action(std::move(update->action_)), get_short_update_date());
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateEncryptedChatTyping> update, bool /*force_apply*/) {
|
||||
@ -1665,7 +1673,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateEncryptedChatTy
|
||||
}
|
||||
|
||||
td_->messages_manager_->on_user_dialog_action(dialog_id, user_id, make_tl_object<td_api::chatActionTyping>(),
|
||||
G()->unix_time_cached());
|
||||
get_short_update_date());
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserStatus> update, bool /*force_apply*/) {
|
||||
|
@ -107,6 +107,8 @@ class UpdatesManager : public Actor {
|
||||
int32 seq_ = 0;
|
||||
string date_source_ = "nowhere";
|
||||
|
||||
int32 short_update_date_ = 0;
|
||||
|
||||
std::multimap<int32, PendingUpdates> postponed_updates_; // updates received during getDifference
|
||||
std::multimap<int32, PendingUpdates> pending_seq_updates_; // updates with too big seq
|
||||
|
||||
@ -147,6 +149,8 @@ class UpdatesManager : public Actor {
|
||||
|
||||
void set_date(int32 date, bool from_update, string date_source);
|
||||
|
||||
int32 get_short_update_date() const;
|
||||
|
||||
static tl_object_ptr<td_api::ChatAction> convert_send_message_action(
|
||||
tl_object_ptr<telegram_api::SendMessageAction> action);
|
||||
|
||||
|
Reference in New Issue
Block a user