Do not return self in getTopChats.
GitOrigin-RevId: 3ec9d54dbe42447f15ae25fad9e9e8e438af36e8
This commit is contained in:
parent
c2dbb601cf
commit
6afacdd23f
@ -233,19 +233,24 @@ void TopDialogManager::do_get_top_dialogs(GetTopDialogsQuery &&query) {
|
|||||||
CHECK(pos < by_category_.size());
|
CHECK(pos < by_category_.size());
|
||||||
auto &top_dialogs = by_category_[pos];
|
auto &top_dialogs = by_category_[pos];
|
||||||
|
|
||||||
auto limit = min(query.limit, MAX_TOP_DIALOGS_LIMIT);
|
auto limit = std::min({query.limit, MAX_TOP_DIALOGS_LIMIT, top_dialogs.dialogs.size()});
|
||||||
|
|
||||||
limit = min(limit, top_dialogs.dialogs.size());
|
|
||||||
vector<DialogId> dialog_ids = transform(top_dialogs.dialogs, [](const auto &x) { return x.dialog_id; });
|
vector<DialogId> dialog_ids = transform(top_dialogs.dialogs, [](const auto &x) { return x.dialog_id; });
|
||||||
|
|
||||||
auto promise = PromiseCreator::lambda([query = std::move(query), dialog_ids, limit](Result<Unit>) mutable {
|
auto promise = PromiseCreator::lambda([query = std::move(query), dialog_ids, limit](Result<Unit>) mutable {
|
||||||
vector<DialogId> result;
|
vector<DialogId> result;
|
||||||
result.reserve(limit);
|
result.reserve(limit);
|
||||||
for (auto dialog_id : dialog_ids) {
|
for (auto dialog_id : dialog_ids) {
|
||||||
if (dialog_id.get_type() == DialogType::User &&
|
if (dialog_id.get_type() == DialogType::User) {
|
||||||
G()->td().get_actor_unsafe()->contacts_manager_->is_user_deleted(dialog_id.get_user_id())) {
|
auto user_id = dialog_id.get_user_id();
|
||||||
LOG(INFO) << "Skip deleted " << dialog_id.get_user_id();
|
if (G()->td().get_actor_unsafe()->contacts_manager_->is_user_deleted(user_id)) {
|
||||||
continue;
|
LOG(INFO) << "Skip deleted " << user_id;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (G()->td().get_actor_unsafe()->contacts_manager_->get_my_id("do_get_top_dialogs") == user_id) {
|
||||||
|
LOG(INFO) << "Skip self " << user_id;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.push_back(dialog_id);
|
result.push_back(dialog_id);
|
||||||
@ -408,7 +413,6 @@ void TopDialogManager::loop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timestamp wakeup_timeout;
|
|
||||||
if (!pending_get_top_dialogs_.empty()) {
|
if (!pending_get_top_dialogs_.empty()) {
|
||||||
for (auto &query : pending_get_top_dialogs_) {
|
for (auto &query : pending_get_top_dialogs_) {
|
||||||
do_get_top_dialogs(std::move(query));
|
do_get_top_dialogs(std::move(query));
|
||||||
@ -425,6 +429,7 @@ void TopDialogManager::loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timestamp wakeup_timeout;
|
||||||
if (server_sync_state_ == SyncState::Ok) {
|
if (server_sync_state_ == SyncState::Ok) {
|
||||||
wakeup_timeout.relax(server_sync_timeout);
|
wakeup_timeout.relax(server_sync_timeout);
|
||||||
} else if (server_sync_state_ == SyncState::None && was_first_sync_) {
|
} else if (server_sync_state_ == SyncState::None && was_first_sync_) {
|
||||||
|
Reference in New Issue
Block a user