Send updateChatOnlineMemberCount whenever dialog is opened.

GitOrigin-RevId: e85a9f04705da10e6b148d0d4c1b843241620c42
This commit is contained in:
levlam 2019-02-26 03:41:49 +03:00
parent 8795d002de
commit 60e5854fcf
2 changed files with 23 additions and 0 deletions

View File

@ -12833,6 +12833,18 @@ void MessagesManager::open_dialog(Dialog *d) {
default:
UNREACHABLE();
}
if (!td_->auth_manager_->is_bot()) {
auto online_count_it = dialog_online_member_counts_.find(d->dialog_id);
if (online_count_it != dialog_online_member_counts_.end()) {
auto &info = online_count_it->second;
CHECK(!info.is_update_sent);
if (Time::now() - info.updated_time < ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME) {
info.is_update_sent = true;
send_update_chat_online_member_count(d->dialog_id, info.online_member_count);
}
}
}
}
void MessagesManager::close_dialog(Dialog *d) {
@ -12883,6 +12895,14 @@ void MessagesManager::close_dialog(Dialog *d) {
default:
UNREACHABLE();
}
if (!td_->auth_manager_->is_bot()) {
auto online_count_it = dialog_online_member_counts_.find(d->dialog_id);
if (online_count_it != dialog_online_member_counts_.end()) {
auto &info = online_count_it->second;
info.is_update_sent = false;
}
}
}
tl_object_ptr<td_api::ChatType> MessagesManager::get_chat_type_object(DialogId dialog_id) const {

View File

@ -1240,6 +1240,9 @@ class MessagesManager : public Actor {
static constexpr int32 USERNAME_CACHE_EXPIRE_TIME = 3 * 86400;
static constexpr int32 USERNAME_CACHE_EXPIRE_TIME_SHORT = 900;
static constexpr int32 ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME = 30 * 60;
static constexpr int32 ONLINE_MEMBER_COUNT_UPDATE_TIME = 5 * 60;
static constexpr int32 MAX_RESEND_DELAY = 86400; // seconds, some resonable limit
static constexpr int32 MAX_PRELOADED_DIALOGS = 1000;