UpdateChatOnlineMemberCount fixes.
GitOrigin-RevId: ba2ab62da3e665e8e48427bd7607e423aa18e32f
This commit is contained in:
parent
3c61017d87
commit
692f9fcf1a
@ -3159,6 +3159,7 @@ void ContactsManager::set_my_online_status(bool is_online, bool send_update, boo
|
|||||||
if (new_online != my_was_online_local_) {
|
if (new_online != my_was_online_local_) {
|
||||||
my_was_online_local_ = new_online;
|
my_was_online_local_ = new_online;
|
||||||
u->is_status_changed = true;
|
u->is_status_changed = true;
|
||||||
|
u->is_online_status_changed = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (my_was_online_local_ != 0 || new_online != u->was_online) {
|
if (my_was_online_local_ != 0 || new_online != u->was_online) {
|
||||||
@ -3166,6 +3167,7 @@ void ContactsManager::set_my_online_status(bool is_online, bool send_update, boo
|
|||||||
my_was_online_local_ = 0;
|
my_was_online_local_ = 0;
|
||||||
u->was_online = new_online;
|
u->was_online = new_online;
|
||||||
u->is_status_changed = true;
|
u->is_status_changed = true;
|
||||||
|
u->is_online_status_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6993,7 +6995,10 @@ void ContactsManager::on_update_user_online(User *u, UserId user_id, tl_object_p
|
|||||||
u->is_status_changed = true;
|
u->is_status_changed = true;
|
||||||
|
|
||||||
if (user_id == get_my_id()) {
|
if (user_id == get_my_id()) {
|
||||||
my_was_online_local_ = 0;
|
if (my_was_online_local_ != 0 || was_online != is_online) {
|
||||||
|
my_was_online_local_ = 0;
|
||||||
|
u->is_online_status_changed = true;
|
||||||
|
}
|
||||||
if (is_offline) {
|
if (is_offline) {
|
||||||
td_->on_online_updated(false, false);
|
td_->on_online_updated(false, false);
|
||||||
}
|
}
|
||||||
@ -7160,8 +7165,11 @@ void ContactsManager::update_user_online_member_count(User *u) {
|
|||||||
update_chat_online_member_count(chat_full, chat_id, false);
|
update_chat_online_member_count(chat_full, chat_id, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DialogType::Channel:
|
case DialogType::Channel: {
|
||||||
|
auto channel_id = dialog_id.get_channel_id();
|
||||||
|
update_channel_online_member_count(channel_id, false);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case DialogType::User:
|
case DialogType::User:
|
||||||
case DialogType::SecretChat:
|
case DialogType::SecretChat:
|
||||||
case DialogType::None:
|
case DialogType::None:
|
||||||
@ -7495,7 +7503,7 @@ void ContactsManager::on_get_channel_participants_success(
|
|||||||
bot_user_ids = std::move(user_ids);
|
bot_user_ids = std::move(user_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_channel_type(channel_id) == ChannelType::Megagroup) {
|
if (get_channel_type(channel_id) == ChannelType::Megagroup && !td_->auth_manager_->is_bot()) {
|
||||||
cached_channel_participants_[channel_id] = result;
|
cached_channel_participants_[channel_id] = result;
|
||||||
update_channel_online_member_count(channel_id, true);
|
update_channel_online_member_count(channel_id, true);
|
||||||
}
|
}
|
||||||
|
@ -8625,6 +8625,7 @@ void MessagesManager::on_update_dialog_online_member_count_timeout(DialogId dial
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dialog_id.get_type() == DialogType::Chat) {
|
if (dialog_id.get_type() == DialogType::Chat) {
|
||||||
|
// we need actual online status state, so we need to reget chat participants
|
||||||
td_->contacts_manager_->repair_chat_participants(dialog_id.get_chat_id());
|
td_->contacts_manager_->repair_chat_participants(dialog_id.get_chat_id());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -12944,7 +12945,8 @@ void MessagesManager::read_message_contents_on_server(DialogId dialog_id, vector
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::open_dialog(Dialog *d) {
|
void MessagesManager::open_dialog(Dialog *d) {
|
||||||
if (d->is_opened || !have_input_peer(d->dialog_id, AccessRights::Read)) {
|
DialogId dialog_id = d->dialog_id;
|
||||||
|
if (d->is_opened || !have_input_peer(dialog_id, AccessRights::Read)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
d->is_opened = true;
|
d->is_opened = true;
|
||||||
@ -12957,26 +12959,36 @@ void MessagesManager::open_dialog(Dialog *d) {
|
|||||||
m = m->right.get();
|
m = m->right.get();
|
||||||
}
|
}
|
||||||
if (m->message_id.get() < min_message_id) {
|
if (m->message_id.get() < min_message_id) {
|
||||||
read_history_inbox(d->dialog_id, m->message_id, -1, "open_dialog");
|
read_history_inbox(dialog_id, m->message_id, -1, "open_dialog");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO) << "Cancel unload timeout for " << d->dialog_id;
|
LOG(INFO) << "Cancel unload timeout for " << dialog_id;
|
||||||
pending_unload_dialog_timeout_.cancel_timeout(d->dialog_id.get());
|
pending_unload_dialog_timeout_.cancel_timeout(dialog_id.get());
|
||||||
|
|
||||||
if (d->new_secret_chat_notification_id.is_valid()) {
|
if (d->new_secret_chat_notification_id.is_valid()) {
|
||||||
remove_new_secret_chat_notification(d, true);
|
remove_new_secret_chat_notification(d, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_dialog_pinned_message(d->dialog_id, Auto());
|
get_dialog_pinned_message(dialog_id, Auto());
|
||||||
|
|
||||||
switch (d->dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
case DialogType::User:
|
case DialogType::User:
|
||||||
break;
|
break;
|
||||||
case DialogType::Chat:
|
case DialogType::Chat:
|
||||||
|
td_->contacts_manager_->repair_chat_participants(dialog_id.get_chat_id());
|
||||||
break;
|
break;
|
||||||
case DialogType::Channel:
|
case DialogType::Channel:
|
||||||
get_channel_difference(d->dialog_id, d->pts, true, "open_dialog");
|
if (!is_broadcast_channel(dialog_id)) {
|
||||||
|
auto participant_count = td_->contacts_manager_->get_channel_participant_count(dialog_id.get_channel_id());
|
||||||
|
if (1 <= participant_count && participant_count < 195) {
|
||||||
|
td_->contacts_manager_->send_get_channel_participants_query(
|
||||||
|
dialog_id.get_channel_id(),
|
||||||
|
ChannelParticipantsFilter(td_api::make_object<td_api::supergroupMembersFilterRecent>()), 0, 200, 0,
|
||||||
|
Auto());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get_channel_difference(dialog_id, d->pts, true, "open_dialog");
|
||||||
break;
|
break;
|
||||||
case DialogType::SecretChat:
|
case DialogType::SecretChat:
|
||||||
break;
|
break;
|
||||||
@ -12986,13 +12998,13 @@ void MessagesManager::open_dialog(Dialog *d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!td_->auth_manager_->is_bot()) {
|
if (!td_->auth_manager_->is_bot()) {
|
||||||
auto online_count_it = dialog_online_member_counts_.find(d->dialog_id);
|
auto online_count_it = dialog_online_member_counts_.find(dialog_id);
|
||||||
if (online_count_it != dialog_online_member_counts_.end()) {
|
if (online_count_it != dialog_online_member_counts_.end()) {
|
||||||
auto &info = online_count_it->second;
|
auto &info = online_count_it->second;
|
||||||
CHECK(!info.is_update_sent);
|
CHECK(!info.is_update_sent);
|
||||||
if (Time::now() - info.updated_time < ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME) {
|
if (Time::now() - info.updated_time < ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME) {
|
||||||
info.is_update_sent = true;
|
info.is_update_sent = true;
|
||||||
send_update_chat_online_member_count(d->dialog_id, info.online_member_count);
|
send_update_chat_online_member_count(dialog_id, info.online_member_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -13004,41 +13016,42 @@ void MessagesManager::close_dialog(Dialog *d) {
|
|||||||
}
|
}
|
||||||
d->is_opened = false;
|
d->is_opened = false;
|
||||||
|
|
||||||
if (have_input_peer(d->dialog_id, AccessRights::Write)) {
|
auto dialog_id = d->dialog_id;
|
||||||
if (pending_draft_message_timeout_.has_timeout(d->dialog_id.get())) {
|
if (have_input_peer(dialog_id, AccessRights::Write)) {
|
||||||
pending_draft_message_timeout_.set_timeout_in(d->dialog_id.get(), 0.0);
|
if (pending_draft_message_timeout_.has_timeout(dialog_id.get())) {
|
||||||
|
pending_draft_message_timeout_.set_timeout_in(dialog_id.get(), 0.0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pending_draft_message_timeout_.cancel_timeout(d->dialog_id.get());
|
pending_draft_message_timeout_.cancel_timeout(dialog_id.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_input_peer(d->dialog_id, AccessRights::Read)) {
|
if (have_input_peer(dialog_id, AccessRights::Read)) {
|
||||||
if (pending_message_views_timeout_.has_timeout(d->dialog_id.get())) {
|
if (pending_message_views_timeout_.has_timeout(dialog_id.get())) {
|
||||||
pending_message_views_timeout_.set_timeout_in(d->dialog_id.get(), 0.0);
|
pending_message_views_timeout_.set_timeout_in(dialog_id.get(), 0.0);
|
||||||
}
|
}
|
||||||
if (pending_read_history_timeout_.has_timeout(d->dialog_id.get())) {
|
if (pending_read_history_timeout_.has_timeout(dialog_id.get())) {
|
||||||
pending_read_history_timeout_.set_timeout_in(d->dialog_id.get(), 0.0);
|
pending_read_history_timeout_.set_timeout_in(dialog_id.get(), 0.0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pending_message_views_timeout_.cancel_timeout(d->dialog_id.get());
|
pending_message_views_timeout_.cancel_timeout(dialog_id.get());
|
||||||
d->pending_viewed_message_ids.clear();
|
d->pending_viewed_message_ids.clear();
|
||||||
d->increment_view_counter = false;
|
d->increment_view_counter = false;
|
||||||
|
|
||||||
pending_read_history_timeout_.cancel_timeout(d->dialog_id.get());
|
pending_read_history_timeout_.cancel_timeout(dialog_id.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_message_unload_enabled()) {
|
if (is_message_unload_enabled()) {
|
||||||
LOG(INFO) << "Schedule unload of " << d->dialog_id;
|
LOG(INFO) << "Schedule unload of " << dialog_id;
|
||||||
pending_unload_dialog_timeout_.set_timeout_in(d->dialog_id.get(), get_unload_dialog_delay());
|
pending_unload_dialog_timeout_.set_timeout_in(dialog_id.get(), get_unload_dialog_delay());
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (d->dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
case DialogType::User:
|
case DialogType::User:
|
||||||
break;
|
break;
|
||||||
case DialogType::Chat:
|
case DialogType::Chat:
|
||||||
break;
|
break;
|
||||||
case DialogType::Channel:
|
case DialogType::Channel:
|
||||||
channel_get_difference_timeout_.cancel_timeout(d->dialog_id.get());
|
channel_get_difference_timeout_.cancel_timeout(dialog_id.get());
|
||||||
break;
|
break;
|
||||||
case DialogType::SecretChat:
|
case DialogType::SecretChat:
|
||||||
break;
|
break;
|
||||||
@ -13048,13 +13061,12 @@ void MessagesManager::close_dialog(Dialog *d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!td_->auth_manager_->is_bot()) {
|
if (!td_->auth_manager_->is_bot()) {
|
||||||
auto online_count_it = dialog_online_member_counts_.find(d->dialog_id);
|
auto online_count_it = dialog_online_member_counts_.find(dialog_id);
|
||||||
if (online_count_it != dialog_online_member_counts_.end()) {
|
if (online_count_it != dialog_online_member_counts_.end()) {
|
||||||
auto &info = online_count_it->second;
|
auto &info = online_count_it->second;
|
||||||
info.is_update_sent = false;
|
info.is_update_sent = false;
|
||||||
}
|
}
|
||||||
update_dialog_online_member_count_timeout_.set_timeout_in(d->dialog_id.get(),
|
update_dialog_online_member_count_timeout_.set_timeout_in(dialog_id.get(), ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME);
|
||||||
ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user