1
This commit is contained in:
parent
bc0e7ef7e0
commit
63f5520ae8
@ -57,7 +57,38 @@ struct RecommandFriendTask
|
||||
void Done()
|
||||
{
|
||||
if (context.IsValid()) {
|
||||
std::set<std::string>& exclude_account_ids = context.hum->GetExcludeAccountIds();
|
||||
std::set<std::string> batch_account_ids;
|
||||
cs::SMRecommandFriend msg;
|
||||
for (auto& pair : recommand_friends) {
|
||||
if (msg.friend_list_size() < 4) {
|
||||
*msg.add_friend_list() = pair.second;
|
||||
exclude_account_ids.insert(pair.first);
|
||||
batch_account_ids.insert(pair.first);
|
||||
}
|
||||
}
|
||||
std::shuffle(DBHelper::Instance()->cache_users_list.begin(),
|
||||
DBHelper::Instance()->cache_users_list.end(),
|
||||
std::default_random_engine(rand()));
|
||||
for (auto& user_info : DBHelper::Instance()->cache_users_list) {
|
||||
if (msg.friend_list_size() >= 4) {
|
||||
break;
|
||||
}
|
||||
if (exclude_account_ids.find(user_info->base_data().account_id()) ==
|
||||
exclude_account_ids.end()) {
|
||||
*msg.add_friend_list() = *user_info;
|
||||
exclude_account_ids.insert(user_info->base_data().account_id());
|
||||
batch_account_ids.insert(user_info->base_data().account_id());
|
||||
}
|
||||
}
|
||||
if (exclude_account_ids.size() > 50) {
|
||||
std::vector<std::string> deleted_account_ids;
|
||||
for (auto& account_id : exclude_account_ids) {
|
||||
if (batch_account_ids.find(account_id) == batch_account_ids.end()) {
|
||||
deleted_account_ids.push_back(account_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
context.hum->SendMsg(msg);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user